Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
1e6b654e
Commit
1e6b654e
authored
May 26, 2010
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve SSL-related documentation. Explain how to deal with certificate
chains, do assorted wordsmithing.
parent
092c38a2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
173 additions
and
105 deletions
+173
-105
doc/src/sgml/client-auth.sgml
doc/src/sgml/client-auth.sgml
+28
-23
doc/src/sgml/config.sgml
doc/src/sgml/config.sgml
+14
-12
doc/src/sgml/libpq.sgml
doc/src/sgml/libpq.sgml
+78
-43
doc/src/sgml/runtime.sgml
doc/src/sgml/runtime.sgml
+53
-27
No files found.
doc/src/sgml/client-auth.sgml
View file @
1e6b654e
<!-- $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.13
7 2010/04/21 03:32:53
tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.13
8 2010/05/26 23:49:18
tgl Exp $ -->
<chapter id="client-authentication">
<chapter id="client-authentication">
<title>Client Authentication</title>
<title>Client Authentication</title>
...
@@ -314,9 +314,9 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
...
@@ -314,9 +314,9 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
<listitem>
<listitem>
<para>
<para>
Reject the connection unconditionally. This is useful for
Reject the connection unconditionally. This is useful for
<quote>filtering out</> certain hosts from a group,
e.g.
a
<quote>filtering out</> certain hosts from a group,
for example
a
<literal>reject</> line
blocks
a specific host from connecting,
<literal>reject</> line
could block
a specific host from connecting,
but
a later line allows the remaining hosts in a specific
while
a later line allows the remaining hosts in a specific
network to connect.
network to connect.
</para>
</para>
</listitem>
</listitem>
...
@@ -446,7 +446,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
...
@@ -446,7 +446,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
After the <replaceable>auth-method</> field, there can be field(s) of
After the <replaceable>auth-method</> field, there can be field(s) of
the form <replaceable>name</><literal>=</><replaceable>value</> that
the form <replaceable>name</><literal>=</><replaceable>value</> that
specify options for the authentication method. Details about which
specify options for the authentication method. Details about which
options are available for which authentication method appear below.
options are available for which authentication method
s
appear below.
</para>
</para>
</listitem>
</listitem>
</varlistentry>
</varlistentry>
...
@@ -624,17 +624,15 @@ local db1,db2,@demodbs all md5
...
@@ -624,17 +624,15 @@ local db1,db2,@demodbs all md5
in a map should be thought of as meaning <quote>this operating system
in a map should be thought of as meaning <quote>this operating system
user is allowed to connect as this database user</quote>, rather than
user is allowed to connect as this database user</quote>, rather than
implying that they are equivalent. The connection will be allowed if
implying that they are equivalent. The connection will be allowed if
there is any map entry that
matche
s the user name obtained from the
there is any map entry that
pair
s the user name obtained from the
external authentication system
to
the database user name that the
external authentication system
with
the database user name that the
user has requested to connect as.
user has requested to connect as.
</para>
</para>
<para>
<para>
If the <replaceable>system-username</> field starts with a slash (<literal>/</>),
If the <replaceable>system-username</> field starts with a slash (<literal>/</>),
the remainder of the field is treated as a regular expression.
the remainder of the field is treated as a regular expression.
(See <xref linkend="posix-syntax-details"> for details of
(See <xref linkend="posix-syntax-details"> for details of
<productname>PostgreSQL</>'s regular expression syntax.
<productname>PostgreSQL</>'s regular expression syntax.) The regular
Regular expressions in username maps are always treated as being
<quote>advanced</> flavor.) The regular
expression can include a single capture, or parenthesized subexpression,
expression can include a single capture, or parenthesized subexpression,
which can then be referenced in the <replaceable>database-username</>
which can then be referenced in the <replaceable>database-username</>
field as <literal>\1</> (backslash-one). This allows the mapping of
field as <literal>\1</> (backslash-one). This allows the mapping of
...
@@ -768,7 +766,7 @@ omicron bryanh guest1
...
@@ -768,7 +766,7 @@ omicron bryanh guest1
The password-based authentication methods are <literal>md5</>
The password-based authentication methods are <literal>md5</>
and <literal>password</>. These methods operate
and <literal>password</>. These methods operate
similarly except for the way that the password is sent across the
similarly except for the way that the password is sent across the
connection,
i.e. respectively, MD5-hashed and clear-text
.
connection,
namely MD5-hashed and clear-text respectively
.
</para>
</para>
<para>
<para>
...
@@ -811,7 +809,7 @@ omicron bryanh guest1
...
@@ -811,7 +809,7 @@ omicron bryanh guest1
authentication according to RFC 1964. <productname>GSSAPI</productname>
authentication according to RFC 1964. <productname>GSSAPI</productname>
provides automatic authentication (single sign-on) for systems
provides automatic authentication (single sign-on) for systems
that support it. The authentication itself is secure, but the
that support it. The authentication itself is secure, but the
data sent over the database connection will be sen
d
unencrypted unless
data sent over the database connection will be sen
t
unencrypted unless
<acronym>SSL</acronym> is used.
<acronym>SSL</acronym> is used.
</para>
</para>
...
@@ -821,6 +819,9 @@ omicron bryanh guest1
...
@@ -821,6 +819,9 @@ omicron bryanh guest1
in the format
in the format
<literal><replaceable>servicename</>/<replaceable>hostname</>@<replaceable>realm</></literal>. For information about the parts of the principal, and
<literal><replaceable>servicename</>/<replaceable>hostname</>@<replaceable>realm</></literal>. For information about the parts of the principal, and
how to set up the required keys, see <xref linkend="kerberos-auth">.
how to set up the required keys, see <xref linkend="kerberos-auth">.
</para>
<para>
GSSAPI support has to be enabled when <productname>PostgreSQL</> is built;
GSSAPI support has to be enabled when <productname>PostgreSQL</> is built;
see <xref linkend="installation"> for more information.
see <xref linkend="installation"> for more information.
</para>
</para>
...
@@ -845,7 +846,7 @@ omicron bryanh guest1
...
@@ -845,7 +846,7 @@ omicron bryanh guest1
<listitem>
<listitem>
<para>
<para>
Allows for mapping between system and database usernames. See
Allows for mapping between system and database usernames. See
<xref linkend="auth-username-maps"> for details. For a Kerb
o
ros
<xref linkend="auth-username-maps"> for details. For a Kerb
e
ros
principal <literal>username/hostbased@EXAMPLE.COM</literal>, the
principal <literal>username/hostbased@EXAMPLE.COM</literal>, the
username used for mapping is <literal>username/hostbased</literal>
username used for mapping is <literal>username/hostbased</literal>
if <literal>include_realm</literal> is disabled, and
if <literal>include_realm</literal> is disabled, and
...
@@ -948,7 +949,7 @@ omicron bryanh guest1
...
@@ -948,7 +949,7 @@ omicron bryanh guest1
Native Kerberos authentication has been deprecated and should be used
Native Kerberos authentication has been deprecated and should be used
only for backward compatibility. New and upgraded installations are
only for backward compatibility. New and upgraded installations are
encouraged to use the industry-standard <productname>GSSAPI</productname>
encouraged to use the industry-standard <productname>GSSAPI</productname>
authentication (see <xref linkend="gssapi-auth">) instead.
authentication
method
(see <xref linkend="gssapi-auth">) instead.
</para>
</para>
</note>
</note>
...
@@ -1040,7 +1041,7 @@ omicron bryanh guest1
...
@@ -1040,7 +1041,7 @@ omicron bryanh guest1
principal matching the requested database user name. For example, for
principal matching the requested database user name. For example, for
database user name <literal>fred</>, principal
database user name <literal>fred</>, principal
<literal>fred@EXAMPLE.COM</> would be able to connect. To also allow
<literal>fred@EXAMPLE.COM</> would be able to connect. To also allow
princip
le
<literal>fred/users.example.com@EXAMPLE.COM</>, use a username
princip
al
<literal>fred/users.example.com@EXAMPLE.COM</>, use a username
map, as described in <xref linkend="auth-username-maps">.
map, as described in <xref linkend="auth-username-maps">.
</para>
</para>
...
@@ -1121,7 +1122,7 @@ omicron bryanh guest1
...
@@ -1121,7 +1122,7 @@ omicron bryanh guest1
name (with an optional username mapping).
name (with an optional username mapping).
The determination of the client's
The determination of the client's
user name is the security-critical point, and it works differently
user name is the security-critical point, and it works differently
depending on the connection type.
depending on the connection type
, as described below
.
</para>
</para>
<para>
<para>
...
@@ -1195,7 +1196,10 @@ omicron bryanh guest1
...
@@ -1195,7 +1196,10 @@ omicron bryanh guest1
class="osname">Linux</>, <systemitem class="osname">FreeBSD</>,
class="osname">Linux</>, <systemitem class="osname">FreeBSD</>,
<systemitem class="osname">NetBSD</>, <systemitem class="osname">OpenBSD</>,
<systemitem class="osname">NetBSD</>, <systemitem class="osname">OpenBSD</>,
<systemitem class="osname">BSD/OS</>, and <systemitem class="osname">Solaris</systemitem>), ident authentication can also
<systemitem class="osname">BSD/OS</>, and <systemitem class="osname">Solaris</systemitem>), ident authentication can also
be applied to local connections. In this case, no security risk is added by
be applied to local connections.
<productname>PostgreSQL</> uses <symbol>SO_PEERCRED</symbol> to find out
the operating system name of the connected client process.
In this case, no security risk is added by
using ident authentication; indeed it is a preferable choice for
using ident authentication; indeed it is a preferable choice for
local connections on such systems.
local connections on such systems.
</para>
</para>
...
@@ -1272,7 +1276,7 @@ omicron bryanh guest1
...
@@ -1272,7 +1276,7 @@ omicron bryanh guest1
<listitem>
<listitem>
<para>
<para>
Port number on LDAP server to connect to. If no port is specified,
Port number on LDAP server to connect to. If no port is specified,
the
default port in the LDAP library
will be used.
the
LDAP library's default port setting
will be used.
</para>
</para>
</listitem>
</listitem>
</varlistentry>
</varlistentry>
...
@@ -1309,7 +1313,7 @@ omicron bryanh guest1
...
@@ -1309,7 +1313,7 @@ omicron bryanh guest1
<term><literal>ldapbasedn</literal></term>
<term><literal>ldapbasedn</literal></term>
<listitem>
<listitem>
<para>
<para>
DN to root
the search for the user in, when doing search+bind
Root DN to begin
the search for the user in, when doing search+bind
authentication.
authentication.
</para>
</para>
</listitem>
</listitem>
...
@@ -1403,7 +1407,7 @@ ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
...
@@ -1403,7 +1407,7 @@ ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
<para>
<para>
The shared secret used when talking securely to the RADIUS
The shared secret used when talking securely to the RADIUS
server. This must have exactly the same value on the PostgreSQL
server. This must have exactly the same value on the PostgreSQL
and RADIUS servers. It is recommended that this
is
a string of
and RADIUS servers. It is recommended that this
be
a string of
at least 16 characters. This parameter is required.
at least 16 characters. This parameter is required.
<note>
<note>
<para>
<para>
...
@@ -1434,7 +1438,7 @@ ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
...
@@ -1434,7 +1438,7 @@ ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
<para>
<para>
The string used as <literal>NAS Identifier</> in the RADIUS
The string used as <literal>NAS Identifier</> in the RADIUS
requests. This parameter can be used as a second parameter
requests. This parameter can be used as a second parameter
identifying for example which database the user is attempting
identifying for example which database
user
the user is attempting
to authenticate as, which can be used for policy matching on
to authenticate as, which can be used for policy matching on
the RADIUS server. If no identifier is specified, the default
the RADIUS server. If no identifier is specified, the default
<literal>postgresql</> will be used.
<literal>postgresql</> will be used.
...
@@ -1458,7 +1462,8 @@ ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
...
@@ -1458,7 +1462,8 @@ ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
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 certificate. No password prompt will be sent
to the client. The <literal>cn</literal> attribute of the certificate
to the client. The <literal>cn</literal> (Common Name) attribute of the
certificate
will be compared to the requested database username, and if they match
will be compared to the requested database username, and if they match
the login will be allowed. Username mapping can be used to allow
the login will be allowed. Username mapping can be used to allow
<literal>cn</literal> to be different from the database username.
<literal>cn</literal> to be different from the database username.
...
@@ -1548,7 +1553,7 @@ FATAL: no pg_hba.conf entry for host "123.123.123.123", user "andym", database
...
@@ -1548,7 +1553,7 @@ FATAL: no pg_hba.conf entry for host "123.123.123.123", user "andym", database
<para>
<para>
<programlisting>
<programlisting>
FATAL:
P
assword authentication failed for user "andym"
FATAL:
p
assword authentication failed for user "andym"
</programlisting>
</programlisting>
Messages like this indicate that you contacted the server, and it is
Messages like this indicate that you contacted the server, and it is
willing to talk to you, but not until you pass the authorization
willing to talk to you, but not until you pass the authorization
...
...
doc/src/sgml/config.sgml
View file @
1e6b654e
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.27
8 2010/05/20 20:32:27
tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.27
9 2010/05/26 23:49:18
tgl Exp $ -->
<chapter Id="runtime-config">
<chapter Id="runtime-config">
<title>Server Configuration</title>
<title>Server Configuration</title>
...
@@ -614,20 +614,22 @@ SET ENABLE_SEQSCAN TO OFF;
...
@@ -614,20 +614,22 @@ SET ENABLE_SEQSCAN TO OFF;
</indexterm>
</indexterm>
<listitem>
<listitem>
<para>
<para>
Specifies how much data can flow over an <acronym>SSL</> encrypted connection
Specifies how much data can flow over an <acronym>SSL</>-encrypted
before renegotiation of the session will take place. Renegotiation of the
connection before renegotiation of the session keys will take
session decreases the chance of doing cryptanalysis when large amounts of data
place. Renegotiation decreases an attacker's chances of doing
are sent, but it also carries a large performance penalty. The sum of
cryptanalysis when large amounts of traffic can be examined, but it
sent and received traffic is used to check the limit. If the parameter is
also carries a large performance penalty. The sum of sent and received
set to 0, renegotiation is disabled. The default is <literal>512MB</>.
traffic is used to check the limit. If this parameter is set to 0,
renegotiation is disabled. The default is <literal>512MB</>.
</para>
</para>
<note>
<note>
<para>
<para>
SSL libraries from before November 2009 are insecure when using SSL
SSL libraries from before November 2009 are insecure when using SSL
renegotiation, due to a vulnerability in the SSL protocol. As a stop-gap fix
renegotiation, due to a vulnerability in the SSL protocol. As a
for this vulnerability, some vendors also shipped SSL libraries incapable
stop-gap fix for this vulnerability, some vendors shipped SSL
of doing renegotiation. If any of these libraries are in use on the client
libraries incapable of doing renegotiation. If any such libraries
or server, SSL renegotiation should be disabled.
are in use on the client or server, SSL renegotiation should be
disabled.
</para>
</para>
</note>
</note>
</listitem>
</listitem>
...
...
doc/src/sgml/libpq.sgml
View file @
1e6b654e
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.30
5 2010/05/13 14:16:41 mha
Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.30
6 2010/05/26 23:49:18 tgl
Exp $ -->
<chapter id="libpq">
<chapter id="libpq">
<title><application>libpq</application> - C Library</title>
<title><application>libpq</application> - C Library</title>
...
@@ -293,7 +293,7 @@
...
@@ -293,7 +293,7 @@
<term><literal>sslmode</literal></term>
<term><literal>sslmode</literal></term>
<listitem>
<listitem>
<para>
<para>
This option determines whether or with what priority a
This option determines whether or with what priority a
secure
<acronym>SSL</> TCP/IP connection will be negotiated with the
<acronym>SSL</> TCP/IP connection will be negotiated with the
server. There are six modes:
server. There are six modes:
</para>
</para>
...
@@ -337,7 +337,7 @@
...
@@ -337,7 +337,7 @@
<row>
<row>
<entry><literal>verify-ca</></entry>
<entry><literal>verify-ca</></entry>
<entry>only try an <acronym>SSL</> connection, and verify that
<entry>only try an <acronym>SSL</> connection, and verify that
the server certificate is issued by a trusted <acronym>CA</>
.
the server certificate is issued by a trusted <acronym>CA</>
</entry>
</entry>
</row>
</row>
...
@@ -345,7 +345,7 @@
...
@@ -345,7 +345,7 @@
<entry><literal>verify-full</></entry>
<entry><literal>verify-full</></entry>
<entry>only try an <acronym>SSL</> connection, verify that
<entry>only try an <acronym>SSL</> connection, verify that
the server certificate is issued by a trusted <acronym>CA</> and
the server certificate is issued by a trusted <acronym>CA</> and
that the server hostname matches that in the certificate
.
</entry>
that the server hostname matches that in the certificate</entry>
</row>
</row>
</tbody>
</tbody>
...
@@ -361,7 +361,8 @@
...
@@ -361,7 +361,8 @@
<literal>sslmode</> is ignored for Unix domain socket
<literal>sslmode</> is ignored for Unix domain socket
communication.
communication.
If <productname>PostgreSQL</> is compiled without SSL support,
If <productname>PostgreSQL</> is compiled without SSL support,
using option <literal>require</> will cause an error, while
using options <literal>require</>, <literal>verify-ca</>, or
<literal>verify-full</> will cause an error, while
options <literal>allow</> and <literal>prefer</> will be
options <literal>allow</> and <literal>prefer</> will be
accepted but <application>libpq</> will not actually attempt
accepted but <application>libpq</> will not actually attempt
an <acronym>SSL</>
an <acronym>SSL</>
...
@@ -398,7 +399,9 @@
...
@@ -398,7 +399,9 @@
<listitem>
<listitem>
<para>
<para>
This parameter specifies the file name of the client SSL
This parameter specifies the file name of the client SSL
certificate.
certificate, replacing the default
<filename>~/.postgresql/postgresql.crt</>.
This parameter is ignored if an SSL connection is not made.
</para>
</para>
</listitem>
</listitem>
</varlistentry>
</varlistentry>
...
@@ -407,13 +410,15 @@
...
@@ -407,13 +410,15 @@
<term><literal>sslkey</literal></term>
<term><literal>sslkey</literal></term>
<listitem>
<listitem>
<para>
<para>
This parameter specifies the location for the secret key
This parameter specifies the location for the secret key used for
used for the client certificate. It can either specify a filename
the client certificate. It can either specify a filename that will
that will be used instead of the default
be used instead of the default
<filename>~/.postgresql/postgresql.key</>, or can specify an external
<filename>~/.postgresql/postgresql.key</>, or it can specify a key
engine (engines are <productname>OpenSSL</> loadable modules). The
obtained from an external <quote>engine</> (engines are
external engine specification should consist of a colon-separated
<productname>OpenSSL</> loadable modules). An external engine
engine name and an engine-specific key identifier.
specification should consist of a colon-separated engine name and
an engine-specific key identifier. This parameter is ignored if an
SSL connection is not made.
</para>
</para>
</listitem>
</listitem>
</varlistentry>
</varlistentry>
...
@@ -422,7 +427,11 @@
...
@@ -422,7 +427,11 @@
<term><literal>sslrootcert</literal></term>
<term><literal>sslrootcert</literal></term>
<listitem>
<listitem>
<para>
<para>
This parameter specifies the file name of the root SSL certificate.
This parameter specifies the name of a file containing SSL
certificate authority (<acronym>CA</>) certificate(s).
If the file exists, the server's certificate will be verified
to be signed by one of these authorities. The default is
<filename>~/.postgresql/root.crt</>.
</para>
</para>
</listitem>
</listitem>
</varlistentry>
</varlistentry>
...
@@ -432,7 +441,10 @@
...
@@ -432,7 +441,10 @@
<listitem>
<listitem>
<para>
<para>
This parameter specifies the file name of the SSL certificate
This parameter specifies the file name of the SSL certificate
revocation list (CRL).
revocation list (CRL). Certificates listed in this file, if it
exists, will be rejected while attempting to authenticate the
server's certificate. The default is
<filename>~/.postgresql/root.crl</>.
</para>
</para>
</listitem>
</listitem>
</varlistentry>
</varlistentry>
...
@@ -1482,8 +1494,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
...
@@ -1482,8 +1494,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<para>
<para>
You must define <symbol>USE_SSL</symbol> in order to get the
You must define <symbol>USE_SSL</symbol> in order to get the
correct prototype for this function. Doing this will also
correct prototype for this function. Doing so will also
automatically include <filename>ssl.h</filename> from <productname>OpenSSL</productname>.
automatically include <filename>ssl.h</filename> from
<productname>OpenSSL</productname>.
</para>
</para>
</listitem>
</listitem>
</varlistentry>
</varlistentry>
...
@@ -6398,23 +6411,24 @@ user=admin
...
@@ -6398,23 +6411,24 @@ user=admin
By default, <productname>PostgreSQL</> will not perform any verification of
By default, <productname>PostgreSQL</> will not perform any verification of
the server certificate. This means that it is possible to spoof the server
the server certificate. This means that it is possible to spoof the server
identity (for example by modifying a DNS record or by taking over the server
identity (for example by modifying a DNS record or by taking over the server
IP address) without the client knowing. In order to prevent
this
,
IP address) without the client knowing. In order to prevent
spoofing
,
<acronym>SSL</> certificate verification must be used.
<acronym>SSL</> certificate verification must be used.
</para>
</para>
<para>
<para>
If the parameter <literal>sslmode</> is set to <literal>verify-ca</>
If the parameter <literal>sslmode</> is set to <literal>verify-ca</>,
libpq will verify that the server is trustworthy by checking the certificate
libpq will verify that the server is trustworthy by checking the
chain up to a trusted <acronym>CA</>. If <literal>sslmode</> is set to
certificate chain up to a trusted certificate authority
<literal>verify-full</>, libpq will <emphasis>also</> verify that the server
(<acronym>CA</>). If <literal>sslmode</> is set to <literal>verify-full</>,
hostname matches that of the certificate. The SSL connection will fail if
libpq will <emphasis>also</> verify that the server hostname matches its
the server certificate cannot be verified. <literal>verify-full</> is
certificate. The SSL connection will fail if the server certificate cannot
recommended in most security sensitive environments.
be verified. <literal>verify-full</> is recommended in most
security-sensitive environments.
</para>
</para>
<para>
<para>
In <literal>verify-full</> mode, the <literal>cn</>
attribute of th
e
In <literal>verify-full</> mode, the <literal>cn</>
(Common Name) attribut
e
certificate is matched against the hostname. If the <literal>cn</>
of the
certificate is matched against the hostname. If the <literal>cn</>
attribute starts with an asterisk (<literal>*</>), it will be treated as
attribute starts with an asterisk (<literal>*</>), it will be treated as
a wildcard, and will match all characters <emphasis>except</> a dot
a wildcard, and will match all characters <emphasis>except</> a dot
(<literal>.</>). This means the certificate will not match subdomains.
(<literal>.</>). This means the certificate will not match subdomains.
...
@@ -6423,7 +6437,8 @@ user=admin
...
@@ -6423,7 +6437,8 @@ user=admin
</para>
</para>
<para>
<para>
To allow verification, the certificate of a trusted <acronym>CA</> must be
To allow server certificate verification, the certificate(s) of one or more
trusted <acronym>CA</>s must be
placed in the file <filename>~/.postgresql/root.crt</> in the user's home
placed in the file <filename>~/.postgresql/root.crt</> in the user's home
directory. (On Microsoft Windows the file is named
directory. (On Microsoft Windows the file is named
<filename>%APPDATA%\postgresql\root.crt</filename>.)
<filename>%APPDATA%\postgresql\root.crt</filename>.)
...
@@ -6437,8 +6452,9 @@ user=admin
...
@@ -6437,8 +6452,9 @@ user=admin
</para>
</para>
<para>
<para>
The location of the root certificate store and the CRL can be overridden
The location of the root certificate file and the CRL can be changed by
by the connection parameters <literal>sslrootcert</> and <literal>sslcrl</>
setting
the connection parameters <literal>sslrootcert</> and <literal>sslcrl</>
or the environment variables <envar>PGSSLROOTCERT</> and <envar>PGSSLCRL</>.
or the environment variables <envar>PGSSLROOTCERT</> and <envar>PGSSLCRL</>.
</para>
</para>
</sect2>
</sect2>
...
@@ -6465,6 +6481,24 @@ user=admin
...
@@ -6465,6 +6481,24 @@ user=admin
environment variables <envar>PGSSLCERT</> and <envar>PGSSLKEY</>.
environment variables <envar>PGSSLCERT</> and <envar>PGSSLKEY</>.
</para>
</para>
<para>
In some cases, the client certificate might be signed by an
<quote>intermediate</> certificate authority, rather than one that is
directly trusted by the server. To use such a certificate, append the
certificate of the signing authority to the <filename>postgresql.crt</>
file, then its parent authority's certificate, and so on up to a
<quote>root</> authority that is trusted by the server. The root
certificate should be included in every case where
<filename>postgresql.crt</> contains more than one certificate.
</para>
<para>
Note that <filename>root.crt</filename> lists the top-level CAs that are
considered trusted for signing server certificates. In principle it need
not list the CA that signed the client's certificate, though in most cases
that CA would also be trusted for server certificates.
</para>
</sect2>
</sect2>
<sect2 id="libpq-ssl-protection">
<sect2 id="libpq-ssl-protection">
...
@@ -6472,8 +6506,8 @@ user=admin
...
@@ -6472,8 +6506,8 @@ user=admin
<para>
<para>
The different values for the <literal>sslmode</> parameter provide different
The different values for the <literal>sslmode</> parameter provide different
levels of protection
, in different environments. SSL itself provides
levels of protection
. SSL can provide
protection against three
different
types of attacks:
protection against three types of attacks:
</para>
</para>
<table id="libpq-ssl-protect-attacks">
<table id="libpq-ssl-protect-attacks">
<title>SSL attacks</title>
<title>SSL attacks</title>
...
@@ -6488,7 +6522,7 @@ user=admin
...
@@ -6488,7 +6522,7 @@ user=admin
<tbody>
<tbody>
<row>
<row>
<entry>Eavesdropping</entry>
<entry>Eavesdropping</entry>
<entry>If a third party can
listen to
the network traffic between the
<entry>If a third party can
examine
the network traffic between the
client and the server, it can read both connection information (including
client and the server, it can read both connection information (including
the username and password) and the data that is passed. <acronym>SSL</>
the username and password) and the data that is passed. <acronym>SSL</>
uses encryption to prevent this.
uses encryption to prevent this.
...
@@ -6523,27 +6557,28 @@ user=admin
...
@@ -6523,27 +6557,28 @@ user=admin
</table>
</table>
<para>
<para>
For a connection to be known secure,
the two first of these have to be
For a connection to be known secure,
SSL usage must be configured
set up
on <emphasis>both the client and the server</> before the connection
on <emphasis>both the client and the server</> before the connection
is made. If it is only configured on the server, the client may end up
is made. If it is only configured on the server, the client may end up
sending sensitive information (e.g. passwords) before
sending sensitive information (e.g. passwords) before
it knows that the server requires high security. In libpq, this is controlled
it knows that the server requires high security. In libpq, secure
connections can be ensured
by setting the <literal>sslmode</> parameter to <literal>verify-full</> or
by setting the <literal>sslmode</> parameter to <literal>verify-full</> or
<literal>verify-ca</>, and providing the system with a root certificate to
<literal>verify-ca</>, and providing the system with a root certificate to
verify against. This is analogous to using a <literal>https</>
verify against. This is analogous to using a
n
<literal>https</>
<acronym>URL</> for encrypted web browsing.
<acronym>URL</> for encrypted web browsing.
</para>
</para>
<para>
<para>
Once the server has been authenticated, the client can pass sensitive data.
Once the server has been authenticated, the client can pass sensitive data.
This means that up until this point, the client does not need to know if
This means that up until this point, the client does not need to know if
certificates will be used for authentication, making it safe to specify th
is
certificates will be used for authentication, making it safe to specify th
at
only in the server configuration.
only in the server configuration.
</para>
</para>
<para>
<para>
All <acronym>SSL</> options carry overhead in the form of encryption and
All <acronym>SSL</> options carry overhead in the form of encryption and
key-exchange,
and it
is a tradeoff that has to be made between performance
key-exchange,
so there
is a tradeoff that has to be made between performance
and security. The following table illustrates the risks the different
and security. The following table illustrates the risks the different
<literal>sslmode</> values protect against, and what statement they make
<literal>sslmode</> values protect against, and what statement they make
about security and overhead:
about security and overhead:
...
@@ -6625,8 +6660,8 @@ user=admin
...
@@ -6625,8 +6660,8 @@ user=admin
The difference between <literal>verify-ca</> and <literal>verify-full</>
The difference between <literal>verify-ca</> and <literal>verify-full</>
depends on the policy of the root <acronym>CA</>. If a public
depends on the policy of the root <acronym>CA</>. If a public
<acronym>CA</> is used, <literal>verify-ca</> allows connections to a server
<acronym>CA</> is used, <literal>verify-ca</> allows connections to a server
that <emphasis>somebody else</> may have registered with the <acronym>CA</>
that <emphasis>somebody else</> may have registered with the <acronym>CA</>
.
to succeed.
In this case, <literal>verify-full</> should always be used. If
In this case, <literal>verify-full</> should always be used. If
a local <acronym>CA</> is used, or even a self-signed certificate, using
a local <acronym>CA</> is used, or even a self-signed certificate, using
<literal>verify-ca</> often provides enough protection.
<literal>verify-ca</> often provides enough protection.
</para>
</para>
...
@@ -6635,7 +6670,7 @@ user=admin
...
@@ -6635,7 +6670,7 @@ user=admin
The default value for <literal>sslmode</> is <literal>prefer</>. As is shown
The default value for <literal>sslmode</> is <literal>prefer</>. As is shown
in the table, this makes no sense from a security point of view, and it only
in the table, this makes no sense from a security point of view, and it only
promises performance overhead if possible. It is only provided as the default
promises performance overhead if possible. It is only provided as the default
for backwards compatibility, and not recommended in secure deployments.
for backwards compatibility, and
is
not recommended in secure deployments.
</para>
</para>
</sect2>
</sect2>
...
@@ -6671,7 +6706,7 @@ user=admin
...
@@ -6671,7 +6706,7 @@ user=admin
<row>
<row>
<entry><filename>~/.postgresql/root.crt</></entry>
<entry><filename>~/.postgresql/root.crt</></entry>
<entry>trusted certificate authorities</entry>
<entry>trusted certificate authorities</entry>
<entry>checks server certificate is signed by a trusted certificate
<entry>checks
that
server certificate is signed by a trusted certificate
authority</entry>
authority</entry>
</row>
</row>
...
...
doc/src/sgml/runtime.sgml
View file @
1e6b654e
<!-- $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.43
5 2010/04/30 22:24:50
tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.43
6 2010/05/26 23:49:19
tgl Exp $ -->
<chapter Id="runtime">
<chapter Id="runtime">
<title>Server Setup and Operation</title>
<title>Server Setup and Operation</title>
...
@@ -1438,28 +1438,30 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
...
@@ -1438,28 +1438,30 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
</para>
</para>
<para>
<para>
The simplest way to prevent
invalid servers
for <literal>local</>
The simplest way to prevent
spoofing
for <literal>local</>
connections is to use a Unix domain socket directory (<xref
connections is to use a Unix domain socket directory (<xref
linkend="guc-unix-socket-directory">) that has write permission only
linkend="guc-unix-socket-directory">) that has write permission only
for a trusted local user. This prevents a malicious user from creating
for a trusted local user. This prevents a malicious user from creating
their own socket file in that directory. If you are concerned that
their own socket file in that directory. If you are concerned that
some applications might still reference <filename>/tmp</> for the
some applications might still reference <filename>/tmp</> for the
socket file and hence be vulnerable to spoofing, during operating system
socket file and hence be vulnerable to spoofing, during operating system
startup create symbolic link <filename>/tmp/.s.PGSQL.5432</> that points
startup create
a
symbolic link <filename>/tmp/.s.PGSQL.5432</> that points
to the relocated socket file. You also might need to modify your
to the relocated socket file. You also might need to modify your
<filename>/tmp</> cleanup script to pre
serve
the symbolic link.
<filename>/tmp</> cleanup script to pre
vent removal of
the symbolic link.
</para>
</para>
<para>
<para>
For TCP connections the server
To prevent spoofing on TCP connections, the best solution is to use
must accept only <literal>hostssl</> connections (<xref
SSL certificates and make sure that clients check the server's certificate.
To do that, the server
must be configured to accept only <literal>hostssl</> connections (<xref
linkend="auth-pg-hba-conf">) and have SSL
linkend="auth-pg-hba-conf">) and have SSL
<filename>server.key</filename> (key) and
<filename>server.key</filename> (key) and
<filename>server.crt</filename> (certificate) files (<xref
<filename>server.crt</filename> (certificate) files (<xref
linkend="ssl-tcp">). The TCP client must connect using
linkend="ssl-tcp">). The TCP client must connect using
<literal>sslmode=
'verify-ca'
</> or
<literal>sslmode=
verify-ca
</> or
<literal>
'verify-full'</> and have the required
certificate
<literal>
verify-full</> and have the appropriate root
certificate
file
s present
(<xref linkend="libpq-connect">).
file
installed
(<xref linkend="libpq-connect">).
</para>
</para>
</sect1>
</sect1>
...
@@ -1589,7 +1591,7 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
...
@@ -1589,7 +1591,7 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
on each side, but this provides stronger verification of identity
on each side, but this provides stronger verification of identity
than the mere use of passwords. It prevents a computer from
than the mere use of passwords. It prevents a computer from
pretending to be the server just long enough to read the password
pretending to be the server just long enough to read the password
sen
d by the client. It also helps prevent "man in the middle"
sen
t by the client. It also helps prevent <quote>man in the middle</>
attacks where a computer between the client and server pretends to
attacks where a computer between the client and server pretends to
be the server and reads and passes all data between the client and
be the server and reads and passes all data between the client and
server.
server.
...
@@ -1602,7 +1604,8 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
...
@@ -1602,7 +1604,8 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
<listitem>
<listitem>
<para>
<para>
If the system administrator cannot be trusted, it is necessary
If the system administrator for the server's machine cannot be trusted,
it is necessary
for the client to encrypt the data; this way, unencrypted data
for the client to encrypt the data; this way, unencrypted data
never appears on the database server. Data is encrypted on the
never appears on the database server. Data is encrypted on the
client before being sent to the server, and database results have
client before being sent to the server, and database results have
...
@@ -1686,14 +1689,27 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
...
@@ -1686,14 +1689,27 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
been entered.
been entered.
</para>
</para>
<para>
In some cases, the server certificate might be signed by an
<quote>intermediate</> certificate authority, rather than one that is
directly trusted by clients. To use such a certificate, append the
certificate of the signing authority to the <filename>server.crt</> file,
then its parent authority's certificate, and so on up to a <quote>root</>
authority that is trusted by the clients. The root certificate should
be included in every case where <filename>server.crt</> contains more than
one certificate.
</para>
<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>)
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, and set the <literal>clientcert</literal> parameter
directory, and set the <literal>clientcert</literal> parameter
to <literal>1</literal> on the appropriate line(s) in pg_hba.conf.
to <literal>1</literal> on the appropriate <literal>hostssl</> line(s) in
<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
...
@@ -1707,16 +1723,26 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
...
@@ -1707,16 +1723,26 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
</para>
</para>
<para>
<para>
The <literal>clientcert</literal> option in <filename>pg_hba.conf</>
The <literal>clientcert</literal> option in <filename>pg_hba.conf</> is
is available for all authentication methods, but only for rows
available for all authentication methods, but only for rows specified as
specified as <literal>hostssl</>. Unless specified, the default is
<literal>hostssl</>. When <literal>clientcert</literal> is not specified
not to verify the client certificate.
or is set to <literal>0</>, the server will still verify presented client
certificates against <filename>root.crt</filename> if that file exists
— but it will not insist that a client certificate be presented.
</para>
<para>
Note that <filename>root.crt</filename> lists the top-level CAs that are
considered trusted for signing client certificates. In principle it need
not list the CA that signed the server's certificate, though in most cases
that CA would also be trusted for client certificates.
</para>
</para>
<para>
<para>
You can use the authentication method <literal>cert</> to use the
If you are setting up client certificates, you may wish to use
client certificate for authenticating users. See
the <literal>cert</> authentication method, so that the certificates
<xref linkend="auth-cert"> for details.
control user authentication as well as providing connection security.
See <xref linkend="auth-cert"> for details.
</para>
</para>
</sect2>
</sect2>
...
@@ -1745,13 +1771,13 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
...
@@ -1745,13 +1771,13 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
<row>
<row>
<entry><filename>server.crt</></entry>
<entry><filename>server.crt</></entry>
<entry>server certificate</entry>
<entry>server certificate</entry>
<entry>
requested by client
</entry>
<entry>
sent to client to indicate server's identity
</entry>
</row>
</row>
<row>
<row>
<entry><filename>server.key</></entry>
<entry><filename>server.key</></entry>
<entry>server private key</entry>
<entry>server private key</entry>
<entry>proves server certificate was sent by the owner;
it
does not indicate
<entry>proves server certificate was sent by the owner; does not indicate
certificate owner is trustworthy</entry>
certificate owner is trustworthy</entry>
</row>
</row>
...
@@ -1812,7 +1838,7 @@ chmod og-rwx server.key
...
@@ -1812,7 +1838,7 @@ chmod og-rwx server.key
A self-signed certificate can be used for testing, but a certificate
A self-signed certificate can be used for testing, but a certificate
signed by a certificate authority (<acronym>CA</>) (either one of the
signed by a certificate authority (<acronym>CA</>) (either one of the
global <acronym>CAs</> or a local one) should be used in production
global <acronym>CAs</> or a local one) should be used in production
so th
e client
can verify the server's identity. If all the clients
so th
at clients
can verify the server's identity. If all the clients
are local to the organization, using a local <acronym>CA</> is
are local to the organization, using a local <acronym>CA</> is
recommended.
recommended.
</para>
</para>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment