Commit 745513c7 authored by Tom Lane's avatar Tom Lane

Clarify usage of clientcert authentication option.

For some reason this option wasn't discussed at all in client-auth.sgml.
Document it there, and be more explicit about its relationship to the
"cert" authentication method.  Per gripe from Srikanth Venkatesh.

I failed to resist the temptation to do some minor wordsmithing in the
same area, too.

Discussion: <20160713110357.1410.30407@wrigleys.postgresql.org>
parent 99dd8b05
...@@ -547,6 +547,15 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -547,6 +547,15 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
specify options for the authentication method. Details about which specify options for the authentication method. Details about which
options are available for which authentication methods appear below. options are available for which authentication methods appear below.
</para> </para>
<para>
In addition to the method-specific options listed below, there is one
method-independent authentication option <literal>clientcert</>, which
can be specified in any <literal>hostssl</> record. When set
to <literal>1</>, this option requires the client to present a valid
(trusted) SSL certificate, in addition to the other requirements of the
authentication method.
</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
...@@ -1632,9 +1641,9 @@ host ... ldap ldapurl="ldap://ldap.example.net/dc=example,dc=net?uid?sub" ...@@ -1632,9 +1641,9 @@ host ... ldap ldapurl="ldap://ldap.example.net/dc=example,dc=net?uid?sub"
This authentication method uses SSL client certificates to perform This authentication method uses SSL client certificates to perform
authentication. It is therefore only available for SSL connections. authentication. It is therefore only available for SSL connections.
When using this authentication method, the server will require that When using this authentication method, the server will require that
the client provide a valid certificate. No password prompt will be sent the client provide a valid, trusted certificate. No password prompt
to the client. The <literal>cn</literal> (Common Name) attribute of the will be sent to the client. The <literal>cn</literal> (Common Name)
certificate attribute of the certificate
will be compared to the requested database user name, and if they match will be compared to the requested database user name, and if they match
the login will be allowed. User name mapping can be used to allow the login will be allowed. User name mapping can be used to allow
<literal>cn</literal> to be different from the database user name. <literal>cn</literal> to be different from the database user name.
...@@ -1655,6 +1664,16 @@ host ... ldap ldapurl="ldap://ldap.example.net/dc=example,dc=net?uid?sub" ...@@ -1655,6 +1664,16 @@ host ... ldap ldapurl="ldap://ldap.example.net/dc=example,dc=net?uid?sub"
</varlistentry> </varlistentry>
</variablelist> </variablelist>
</para> </para>
<para>
In a <filename>pg_hba.conf</> record specifying certificate
authentication, the authentication option <literal>clientcert</> is
assumed to be <literal>1</>, and it cannot be turned off since a client
certificate is necessary for this method. What the <literal>cert</>
method adds to the basic <literal>clientcert</> certificate validity test
is a check that the <literal>cn</literal> attribute matches the database
user name.
</para>
</sect2> </sect2>
<sect2 id="auth-pam"> <sect2 id="auth-pam">
......
...@@ -2189,20 +2189,23 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433 ...@@ -2189,20 +2189,23 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433
<sect2 id="ssl-client-certificates"> <sect2 id="ssl-client-certificates">
<title>Using Client Certificates</title> <title>Using Client Certificates</title>
<para> <para>
To require the client to supply a trusted certificate, place To require the client to supply a trusted certificate, place
certificates of the certificate authorities (<acronym>CA</acronym>s) certificates of the certificate authorities (<acronym>CA</acronym>s)
you trust in the file <filename>root.crt</filename> in the data you trust in the file <filename>root.crt</filename> in the data
directory, set the parameter <xref linkend="guc-ssl-ca-file"> in directory, set the parameter <xref linkend="guc-ssl-ca-file"> in
<filename>postgresql.conf</filename> to <literal>root.crt</literal>, <filename>postgresql.conf</filename> to <literal>root.crt</literal>,
and set the <literal>clientcert</literal> parameter and add the authentication option <literal>clientcert=1</literal> to the
to 1 on the appropriate <literal>hostssl</> line(s) in appropriate <literal>hostssl</> line(s) in <filename>pg_hba.conf</>.
<filename>pg_hba.conf</>.
A certificate will then be requested from the client during A certificate will then be requested from the client during
SSL connection startup. (See <xref linkend="libpq-ssl"> for a SSL connection startup. (See <xref linkend="libpq-ssl"> for a
description of how to set up certificates on the client.) The server will description of how to set up certificates on the client.) The server will
verify that the client's certificate is signed by one of the trusted verify that the client's certificate is signed by one of the trusted
certificate authorities. If intermediate <acronym>CA</>s appear in certificate authorities.
</para>
<para>
If intermediate <acronym>CA</>s appear in
<filename>root.crt</filename>, the file must also contain certificate <filename>root.crt</filename>, the file must also contain certificate
chains to their root <acronym>CA</>s. Certificate Revocation List chains to their root <acronym>CA</>s. Certificate Revocation List
(CRL) entries (CRL) entries
...@@ -2214,12 +2217,12 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433 ...@@ -2214,12 +2217,12 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433
</para> </para>
<para> <para>
The <literal>clientcert</literal> option in <filename>pg_hba.conf</> is The <literal>clientcert</literal> authentication option is available for
available for all authentication methods, but only for rows specified as all authentication methods, but only in <filename>pg_hba.conf</> lines
<literal>hostssl</>. When <literal>clientcert</literal> is not specified specified as <literal>hostssl</>. When <literal>clientcert</literal> is
or is set to 0, the server will still verify presented client not specified or is set to 0, the server will still verify any presented
certificates against its CA list, if one is configured, client certificates against its CA file, if one is configured &mdash; but
&mdash; but it will not insist that a client certificate be presented. it will not insist that a client certificate be presented.
</para> </para>
<para> <para>
...@@ -2234,7 +2237,9 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433 ...@@ -2234,7 +2237,9 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433
If you are setting up client certificates, you may wish to use If you are setting up client certificates, you may wish to use
the <literal>cert</> authentication method, so that the certificates the <literal>cert</> authentication method, so that the certificates
control user authentication as well as providing connection security. control user authentication as well as providing connection security.
See <xref linkend="auth-cert"> for details. See <xref linkend="auth-cert"> for details. (It is not necessary to
specify <literal>clientcert=1</literal> explicitly when using
the <literal>cert</> authentication method.)
</para> </para>
</sect2> </sect2>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment