<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Vivek Shukla - Redis</title>
    <subtitle>I am a Software Engineer from India. I am currently building Daestro. I work in Rust, Javascript and Python.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://vshukla.com/tags/redis/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://vshukla.com/tags/redis/"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2025-09-08T00:00:00+00:00</updated>
    <id>https://vshukla.com/tags/redis/atom.xml</id>
    <entry xml:lang="en">
        <title>Setup Redis TLS With Self-signed Certificate</title>
        <published>2025-09-08T00:00:00+00:00</published>
        <updated>2025-09-08T00:00:00+00:00</updated>
        <author>
          <name>Vivek Shukla</name>
        </author>
        <link rel="alternate" type="text/html" href="https://vshukla.com/tech/setup-redis-tls-with-self-signed-certs/"/>
        <id>https://vshukla.com/tech/setup-redis-tls-with-self-signed-certs/</id>
        <summary type="html">Brief guide on how to setup Redis TLS using Self-signed certificate.</summary>
        <content type="html" xml:base="https://vshukla.com/tech/setup-redis-tls-with-self-signed-certs/">&lt;blockquote&gt;
&lt;p&gt;This method is only recommended when connecting to redis server via local network.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;generate-server-certificates&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#generate-server-certificates&quot; aria-label=&quot;Anchor link for: generate-server-certificates&quot;&gt;🔗&lt;&#x2F;a&gt;Generate Server Certificates&lt;&#x2F;h2&gt;
&lt;p&gt;Generate Cert and Key file for self signed TLS, then move both these files to redis directory and set the proper permissions. Delete the Key file and copy the cert file to the client machine which will connect to the redis-server.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-function&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; ~&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;openssl&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; req&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other&quot;&gt; -x509 -nodes -days&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 3650&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other&quot;&gt; -newkey&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; rsa:2048&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-constant z-other&quot;&gt;  -keyout&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; redis_tls.key&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other&quot;&gt; -out&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; redis_tls.crt&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-constant z-other&quot;&gt;  -subj&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &amp;quot;&#x2F;CN=YourOrg&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; cp redis_tls.key redis_tls.crt &#x2F;etc&#x2F;redis&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator&quot;&gt; &amp;amp;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name&quot;&gt; rm&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; redis_tls.key&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; chmod&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 600&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;etc&#x2F;redis&#x2F;redis_tls.key&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; chmod&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 644&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;etc&#x2F;redis&#x2F;redis_tls.crt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; chown redis:redis &#x2F;etc&#x2F;redis&#x2F;redis_tls.key&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; chown redis:redis &#x2F;etc&#x2F;redis&#x2F;redis_tls.crt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;update-redis-configuration-file&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#update-redis-configuration-file&quot; aria-label=&quot;Anchor link for: update-redis-configuration-file&quot;&gt;🔗&lt;&#x2F;a&gt;Update Redis Configuration File&lt;&#x2F;h2&gt;
&lt;p&gt;This command will append the value to &lt;code&gt;redis.conf&lt;&#x2F;code&gt; (redis configuration file). Make sure to update the password.&lt;&#x2F;p&gt;
&lt;p&gt;It will disable the non-tls support and enable the tls connection at port &lt;code&gt;6379&lt;&#x2F;code&gt; with previously generated key and cert files.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; tee&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other&quot;&gt; -a&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;etc&#x2F;redis&#x2F;redis.conf&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; &amp;lt;&amp;lt;&lt;&#x2F;span&gt;&lt;span&gt; EOF&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;bind * -::*&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;port 0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;tls-port 6379&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;tls-cert-file &#x2F;etc&#x2F;redis&#x2F;redis_tls.crt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;tls-key-file &#x2F;etc&#x2F;redis&#x2F;redis_tls.key&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;tls-auth-clients no&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;tls-prefer-server-ciphers yes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;requirepass YOUR_PASSWORD_HERE&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;EOF&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Restart and enable redis&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; systemctl restart redis-server&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; systemctl enable redis-server&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Check status with&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; systemctl status redis-server&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;If any error then check journal (log)&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; journalctl&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other&quot;&gt; -u&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; redis-server&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-other&quot;&gt; -f&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;add-redis-certificate-to-trusted-ca-store-in-client-machine&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#add-redis-certificate-to-trusted-ca-store-in-client-machine&quot; aria-label=&quot;Anchor link for: add-redis-certificate-to-trusted-ca-store-in-client-machine&quot;&gt;🔗&lt;&#x2F;a&gt;Add Redis Certificate to Trusted CA Store in Client Machine&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-comment&quot;&gt;# Copy your certificate to CA certificates directory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; mv redis_tls.crt &#x2F;usr&#x2F;local&#x2F;share&#x2F;ca-certificates&#x2F;redis_tls.crt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-comment&quot;&gt;# Update CA certificates&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; update-ca-certificates&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;redis-connection-url&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#redis-connection-url&quot; aria-label=&quot;Anchor link for: redis-connection-url&quot;&gt;🔗&lt;&#x2F;a&gt;Redis Connection URL&lt;&#x2F;h2&gt;
&lt;p&gt;Since we want to connect to redis using TLS connection, so the protocol in the url will be &lt;code&gt;rediss&lt;&#x2F;code&gt; (with double “ss”).&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;rediss:&#x2F;&#x2F;:&amp;lt;your_password_here&amp;gt;@&amp;lt;redis_server_ip&amp;gt;:6379&#x2F;0#insecure&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;</content>
    </entry>
</feed>
