{"id":657,"date":"2020-09-16T22:25:19","date_gmt":"2020-09-16T16:25:19","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=657"},"modified":"2020-09-16T22:25:19","modified_gmt":"2020-09-16T16:25:19","slug":"how-to-access-redis-over-tls-ssl","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/how-to-access-redis-over-tls-ssl.html","title":{"rendered":"How to Access Redis over TLS\/SSL"},"content":{"rendered":"\n<p>If you are trying to purchase Managed Redis Database, from companies like digitalocean, then, you would get access to those Redis servers, only over TLS\/SSL support. Unfortunately, by default redis-cli does not ship with TLS support, hence, you need to either use Tunnel to access redis instance through redis-cli or use different tool for your purpose. <\/p>\n\n\n\n<p><strong>Access Your Redis Instance using Python<\/strong><\/p>\n\n\n\n<p>If you are developing your application using python, and using a managed redis database, then, you would have to make the redis connection over TLS\/SSL. This can be done by setting the &#8216;SSL&#8217; to True, in the Redis constructor. Here is an example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import redis\n\nr = redis.Redis(host='db-redis-sfo2-89862-do-user-4233327-0.b.db.ondigitalocean.com', port=25061, password='abcdhjnmjtxeupp', decode_responses=True, ssl=True)<\/pre>\n\n\n\n<p>As you can see, I have set the ssl to True at the end, to set the connection over TLS\/SSL.<\/p>\n\n\n\n<p><strong>Access Your Redis from Command Line using Redli<\/strong><\/p>\n\n\n\n<p>If you want to have access to your redis instance through a command line tool, then using redli is my first line choice. Configuring stunnel with redis-cli is also possible, but it would be another topic of discussion here. <\/p>\n\n\n\n<p>Let&#8217;s see, how can we install redli:<\/p>\n\n\n\n<p>Redli is a tool developed by IBM with TLS\/SSL support. It is written in Golang. You may download a version for Linux from the IBMCloud Github repo and start using it:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">~ wget https:\/\/github.com\/IBM-Cloud\/redli\/releases\/download\/v0.4.4\/redli_0.4.4_linux_amd64.tar.gz\n~ tar -xvzf redli_0.4.4_linux_amd64.tar.gz\n~ cp redli \/usr\/bin\/\n~ chmod +x \/usr\/bin\/redli\n<\/pre>\n\n\n\n<p>Now, you may use redli to connect to your Redis database with TLS enabled as following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">redli --tls -h db-redis-sfo2-89862-do-user-4233327-0.b.db.ondigitalocean.com -p 25061 -a abcdhjnmjtxeupp<\/pre>\n\n\n\n<p>See how &#8216;&#8211;tls&#8217; is enabled to access redis over TLS here. Hope this helps.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are trying to purchase Managed Redis Database, from companies like digitalocean, then, you would get access to those Redis servers, only over TLS\/SSL support. Unfortunately, by default redis-cli does not ship with TLS support, hence, you need to either use Tunnel to access redis instance through redis-cli or use different tool for your &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/how-to-access-redis-over-tls-ssl.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Access Redis over TLS\/SSL&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[412,488],"tags":[491,340,490,489],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/657"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=657"}],"version-history":[{"count":1,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/657\/revisions"}],"predecessor-version":[{"id":658,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/657\/revisions\/658"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}