<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – TLS authentication</title>
    <link>/en/security-and-authentication/client-authentication/tls-authentication/</link>
    <description>Recent content in TLS authentication on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/security-and-authentication/client-authentication/tls-authentication/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Security-and-Authentication: Client authentication with TLS</title>
      <link>/en/security-and-authentication/client-authentication/tls-authentication/client-authentication-with-tls/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/security-and-authentication/client-authentication/tls-authentication/client-authentication-with-tls/</guid>
      <description>
        
        
        &lt;p&gt;Database users or roles &lt;a href=&#34;../../../../en/sql-reference/statements/grant-statements/grant-authentication/&#34;&gt;granted&lt;/a&gt; a &lt;code&gt;tls&lt;/code&gt; authentication record can authenticate to OpenText™ Analytics Database with a TLS certificate.&lt;/p&gt;
&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;You must configure the database for &lt;a href=&#34;../../../../en/security-and-authentication/tls-protocol/tls-overview/configuring-client-server-tls/&#34;&gt;mutual mode client-server TLS&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In mutual mode, the client and server must verify each other&#39;s identity before connecting. This mode allows the database to verify the identity of the client and allow them to authenticate the client through their certificate.&lt;/p&gt;
&lt;h2 id=&#34;configuring-tls-authentication&#34;&gt;Configuring TLS authentication&lt;/h2&gt;
&lt;p&gt;The following sections &lt;a href=&#34;../../../../en/security-and-authentication/tls-protocol/tls-overview/generating-tls-certificates-and-keys/&#34;&gt;generate&lt;/a&gt; a private key and certificate for the client. For simplicity, the example signs the client certificate with the following self-signed CA certificate (which has also, in the context of the example, signed the database&#39;s server certificate):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE KEY SSCA_key TYPE &amp;#39;RSA&amp;#39; LENGTH 2048;
=&amp;gt; CREATE CA CERTIFICATE &lt;span class=&#34;code-variable&#34;&gt;ca_certificate&lt;/span&gt;
SUBJECT &amp;#39;/C=US/ST=Massachusetts/L=Cambridge/O=OpenText/OU=Vertica/CN=Vertica Root CA&amp;#39;
VALID FOR 3650
EXTENSIONS &amp;#39;nsComment&amp;#39; = &amp;#39;Self-signed root CA cert&amp;#39;
KEY SSCA_key;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In a production environment, you should instead use a CA certificate from a trusted certificate authority.&lt;/p&gt;
&lt;h3 id=&#34;create-client-keys&#34;&gt;Create client keys&lt;/h3&gt;
&lt;p&gt;The following steps generate a client key and certificate, and then make them available to the client:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Generate the client key:


&lt;pre class=&#34;table-pre chroma language-sql&#34; &gt;
      &lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;
   =&gt; CREATE KEY &lt;span class=&#34;code-variable&#34;&gt;client_private_key&lt;/span&gt; TYPE &#39;RSA&#39; LENGTH 2048;
   CREATE KEY
   &lt;/code&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Generate the client certificate. Mutual TLS requires that the Common Name (&lt;code&gt;CN&lt;/code&gt;) in the &lt;code&gt;SUBJECT&lt;/code&gt; specifies a database username:


&lt;pre class=&#34;table-pre chroma language-sql&#34; &gt;
      &lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;
   =&gt; CREATE CERTIFICATE &lt;span class=&#34;code-variable&#34;&gt;client_certificate&lt;/span&gt;
   SUBJECT &#39;/C=US/ST=Massachusetts/L=Cambridge/O=OpenText/OU=Vertica/CN=dbadmin/emailAddress=&lt;span class=&#34;code-variable&#34;&gt;example&lt;/span&gt;@example.com&#39;
   SIGNED BY &lt;span class=&#34;code-variable&#34;&gt;ca_certificate&lt;/span&gt;
   EXTENSIONS &#39;nsComment&#39; = &#39;Vertica client cert&#39;, &#39;extendedKeyUsage&#39; = &#39;clientAuth&#39;
   KEY &lt;span class=&#34;code-variable&#34;&gt;client_private_key&lt;/span&gt;;
   CREATE CERTIFICATE
   &lt;/code&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;On the client machine, export the client key and client certificate to the client filesystem. The following commands use the &lt;a href=&#34;../../../../en/connecting-to/using-vsql/installing-vsql-client/&#34;&gt;vsql client&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ vsql -At -c &lt;span class=&#34;s2&#34;&gt;&amp;#34;SELECT key FROM cryptographic_keys WHERE name = &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;client_private_key&lt;/span&gt;&amp;#39;;&amp;#34;&lt;/span&gt; -o &lt;span class=&#34;code-variable&#34;&gt;client_private_key&lt;/span&gt;.key
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ vsql -At -c &lt;span class=&#34;s2&#34;&gt;&amp;#34;SELECT certificate_text FROM certificates WHERE name = &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;client_certificate&lt;/span&gt;&amp;#39;;&amp;#34;&lt;/span&gt; -o &lt;span class=&#34;code-variable&#34;&gt;client_cert&lt;/span&gt;.pem
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the preceding command:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-A&lt;/code&gt;: enables unaligned output.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-t&lt;/code&gt;: prevents the command from outputting metadata, such as column names.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-c&lt;/code&gt;: instructs the shell to run one command and then exit.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-o&lt;/code&gt;: writes the query output to the specified filename.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For details about all vsql command line options, see &lt;a href=&#34;../../../../en/connecting-to/using-vsql/connecting-from-command-line/command-line-options/#&#34;&gt;Command-line options&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Copy or move the client key and certificate to a location that your client recognizes.&lt;/p&gt;
&lt;p&gt;The following commands move the client key and certificate to the hidden directory &lt;code&gt;~/.client-creds&lt;/code&gt;, and then grants the file owner read and write permissions with &lt;code&gt;chmod&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ mkdir ~/.client-creds
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ mv &lt;span class=&#34;code-variable&#34;&gt;client_private_key&lt;/span&gt;.key ~/.client-creds/client_key.key
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ mv &lt;span class=&#34;code-variable&#34;&gt;client_cert&lt;/span&gt;.pem ~/.client-creds/client_cert.pem
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ chmod &lt;span class=&#34;m&#34;&gt;600&lt;/span&gt; ~/.client-creds/client_key.key ~/.client-creds/client_cert.pem
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&#34;create-an-authentication-record&#34;&gt;Create an authentication record&lt;/h3&gt;
&lt;p&gt;Next, you must create an &lt;a href=&#34;../../../../en/security-and-authentication/client-authentication/creating-authentication-records/&#34;&gt;authentication record&lt;/a&gt; in the database. An authentication record defines a set of authentication and the access methods for the database. You grant this record to a user or role to control how they authenticate to the database:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-authentication/&#34;&gt;Create the authentication record&lt;/a&gt;. The &lt;code&gt;tls&lt;/code&gt; method requires that clients authenticate with a certificate whose Common Name (CN) specifies a database username:


&lt;pre class=&#34;table-pre chroma language-sql&#34; &gt;
      &lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;
   =&gt; CREATE AUTHENTICATION &lt;span class=&#34;code-variable&#34;&gt;auth_record&lt;/span&gt; METHOD &#39;tls&#39; HOST TLS &#39;0.0.0.0/0&#39;;
   CREATE AUTHENTICATION
   &lt;/code&gt;
&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/grant-statements/grant-authentication/&#34;&gt;Grant the authentication record&lt;/a&gt; to a user or to a role. The following example grants the authentication record to &lt;a href=&#34;../../../../en/admin/db-users-and-privileges/db-roles/predefined-db-roles/public/&#34;&gt;PUBLIC&lt;/a&gt;, the &lt;a href=&#34;../../../../en/admin/db-users-and-privileges/db-roles/enabling-roles-automatically/&#34;&gt;default role&lt;/a&gt; for all users:


&lt;pre class=&#34;table-pre chroma language-sql&#34; &gt;
      &lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;
   =&gt; GRANT AUTHENTICATION &lt;span class=&#34;code-variable&#34;&gt;auth_record&lt;/span&gt; TO PUBLIC;
   GRANT AUTHENTICATION
   &lt;/code&gt;
&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&#34;reject-plaintext-connections&#34;&gt;Reject plaintext connections&lt;/h2&gt;
&lt;p&gt;You can create an authentication record that rejects remote connections from a specified IP range.&lt;/p&gt;
&lt;p&gt;For example, to reject all plaintext client connections, specify the &lt;code&gt;reject&lt;/code&gt; authentication method and the &lt;code&gt;HOST NO TLS&lt;/code&gt; access method as follows:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE AUTHENTICATION RejectNoSSL METHOD &amp;#39;reject&amp;#39; HOST NO TLS &amp;#39;0.0.0.0/0&amp;#39;;  --IPv4
=&amp;gt; CREATE AUTHENTICATION RejectNoSSL METHOD &amp;#39;reject&amp;#39; HOST NO TLS &amp;#39;::/0&amp;#39;;       --IPv6
&lt;/code&gt;&lt;/pre&gt;

      </description>
    </item>
    
  </channel>
</rss>
