-
+
Client Authentication
Reject the connection unconditionally. This is useful for
- filtering out> certain hosts from a group, e.g. a
- reject> line blocks a specific host from connecting,
- but a later line allows the remaining hosts in a specific
+ filtering out> certain hosts from a group, for example a
+ reject> line could block a specific host from connecting,
+ while a later line allows the remaining hosts in a specific
network to connect.
After the auth-method> field, there can be field(s) of
the form name>=>value> that
specify options for the authentication method. Details about which
- options are available for which authentication method appear below.
+ options are available for which authentication methods appear below.
in a map should be thought of as meaning this operating system
user is allowed to connect as this database user, rather than
implying that they are equivalent. The connection will be allowed if
- there is any map entry that matches the user name obtained from the
- external authentication system to the database user name that the
+ there is any map entry that pairs the user name obtained from the
+ external authentication system with the database user name that the
user has requested to connect as.
If the system-username> field starts with a slash (/>),
the remainder of the field is treated as a regular expression.
(See for details of
-
PostgreSQL>'s regular expression syntax.
- Regular expressions in username maps are always treated as being
- advanced> flavor.) The regular
+
PostgreSQL>'s regular expression syntax.) The regular
expression can include a single capture, or parenthesized subexpression,
which can then be referenced in the database-username>
field as \1> (backslash-one). This allows the mapping of
The password-based authentication methods are md5>
and password>. These methods operate
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.
authentication according to RFC 1964.
GSSAPI
provides automatic authentication (single sign-on) for systems
that support it. The authentication itself is secure, but the
- data sent over the database connection will be send unencrypted unless
+ data sent over the database connection will be sent unencrypted unless
in the format
servicename>/hostname>@realm>. For information about the parts of the principal, and
how to set up the required keys, see .
+
+
GSSAPI support has to be enabled when
PostgreSQL> is built;
see for more information.
Allows for mapping between system and database usernames. See
- for details. For a Kerboros
+ for details. For a Kerberos
username used for mapping is username/hostbased
if include_realm is disabled, and
Native Kerberos authentication has been deprecated and should be used
only for backward compatibility. New and upgraded installations are
encouraged to use the industry-standard
GSSAPI
- authentication (see ) instead.
+ authentication method (see ) instead.
principal matching the requested database user name. For example, for
database user name fred>, principal
map, as described in .
name (with an optional username mapping).
The determination of the client's
user name is the security-critical point, and it works differently
- depending on the connection type.
+ depending on the connection type, as described below.
class="osname">Linux>, FreeBSD>,
NetBSD>, OpenBSD>,
BSD/OS>, and Solaris), ident authentication can also
- be applied to local connections. In this case, no security risk is added by
+ be applied to local connections.
+
PostgreSQL> uses SO_PEERCRED 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
local connections on such systems.
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.
ldapbasedn
- 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.
The shared secret used when talking securely to the RADIUS
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.
The string used as NAS Identifier> in the RADIUS
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
the RADIUS server. If no identifier is specified, the default
postgresql> will be used.
authentication. It is therefore only available for SSL connections.
When using this authentication method, the server will require that
the client provide a valid certificate. No password prompt will be sent
- to the client. The cn attribute of the certificate
+ to the client. The cn (Common Name) attribute of the
+ certificate
will be compared to the requested database username, and if they match
the login will be allowed. Username mapping can be used to allow
cn to be different from the database username.
-FATAL: Password authentication failed for user "andym"
+FATAL: password authentication failed for user "andym"
Messages like this indicate that you contacted the server, and it is
willing to talk to you, but not until you pass the authorization
-
+
sslmode
- This option determines whether or with what priority a
+ This option determines whether or with what priority a secure
SSL> TCP/IP connection will be negotiated with the
server. There are six modes:
|
verify-ca>
only try an SSL> connection, and verify that
- the server certificate is issued by a trusted
CA>.
+ the server certificate is issued by a trusted
CA>
verify-full>
only try an SSL> connection, verify that
the server certificate is issued by a trusted
CA> and
- that the server hostname matches that in the certificate.
+ that the server hostname matches that in the certificate
sslmode> is ignored for Unix domain socket
communication.
If
PostgreSQL> is compiled without SSL support,
- using option require> will cause an error, while
+ using options require>, verify-ca>, or
+ verify-full> will cause an error, while
options allow> and prefer> will be
accepted but
libpq> will not actually attempt
This parameter specifies the file name of the client SSL
- certificate.
+ certificate, replacing the default
+ ~/.postgresql/postgresql.crt>.
+ This parameter is ignored if an SSL connection is not made.
sslkey
- This parameter specifies the location for the secret key
- used for the client certificate. It can either specify a filename
- that will be used instead of the default
- ~/.postgresql/postgresql.key>, or can specify an external
- engine (engines are
OpenSSL> loadable modules). The
- external engine specification should consist of a colon-separated
- engine name and an engine-specific key identifier.
+ This parameter specifies the location for the secret key used for
+ the client certificate. It can either specify a filename that will
+ be used instead of the default
+ ~/.postgresql/postgresql.key>, or it can specify a key
+ obtained from an external engine> (engines are
+
OpenSSL> loadable modules). An external engine
+ 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.
sslrootcert
- This parameter specifies the file name of the root SSL certificate.
+ This parameter specifies the name of a file containing SSL
+ certificate authority (
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
+ ~/.postgresql/root.crt>.
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
+ ~/.postgresql/root.crl>.
You must define USE_SSL in order to get the
- correct prototype for this function. Doing this will also
- automatically include
ssl.h from
OpenSSL.
+ correct prototype for this function. Doing so will also
+ automatically include ssl.h from
By default,
PostgreSQL> will not perform any verification of
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
- IP address) without the client knowing. In order to prevent this,
+ IP address) without the client knowing. In order to prevent spoofing,
SSL> certificate verification must be used.
- If the parameter sslmode> is set to verify-ca>
- libpq will verify that the server is trustworthy by checking the certificate
- chain up to a trusted
CA>. If sslmode> is set to
- verify-full>, libpq will also> verify that the server
- hostname matches that of the certificate. The SSL connection will fail if
- the server certificate cannot be verified. verify-full> is
- recommended in most security sensitive environments.
+ If the parameter sslmode> is set to verify-ca>,
+ libpq will verify that the server is trustworthy by checking the
+ certificate chain up to a trusted certificate authority
+ (
CA>). If sslmode> is set to verify-full>,
+ libpq will also> verify that the server hostname matches its
+ certificate. The SSL connection will fail if the server certificate cannot
+ be verified. verify-full> is recommended in most
+ security-sensitive environments.
- In verify-full> mode, the cn> attribute of the
- certificate is matched against the hostname. If the cn>
+ In verify-full> mode, the cn> (Common Name) attribute
+ of the certificate is matched against the hostname. If the cn>
attribute starts with an asterisk (*>), it will be treated as
a wildcard, and will match all characters except> a dot
(.>). This means the certificate will not match subdomains.
- To allow verification, the certificate of a trusted
CA> must be
+ To allow server certificate verification, the certificate(s) of one or more
placed in the file ~/.postgresql/root.crt> in the user's home
directory. (On Microsoft Windows the file is named
%APPDATA%\postgresql\root.crt.)
- The location of the root certificate store and the CRL can be overridden
- by the connection parameters sslrootcert> and sslcrl>
+ The location of the root certificate file and the CRL can be changed by
+ setting
+ the connection parameters sslrootcert> and sslcrl>
or the environment variables PGSSLROOTCERT> and PGSSLCRL>.
environment variables PGSSLCERT> and PGSSLKEY>.
+ In some cases, the client certificate might be signed by an
+ 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 postgresql.crt>
+ file, then its parent authority's certificate, and so on up to a
+ root> authority that is trusted by the server. The root
+ certificate should be included in every case where
+ postgresql.crt> contains more than one certificate.
+
+
+ Note that root.crt 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.
+
+
The different values for the sslmode> parameter provide different
- levels of protection, in different environments. SSL itself provides
- protection against three different types of attacks:
+ levels of protection. SSL can provide
+ protection against three types of attacks:
SSL attacks
|
Eavesdropping
- If a third party can listen to the network traffic between the
+ If a third party can examine the network traffic between the
client and the server, it can read both connection information (including
the username and password) and the data that is passed.
SSL>
uses encryption to prevent this.
- For a connection to be known secure, the two first of these have to be
- set up on both the client and the server> before the connection
+ For a connection to be known secure, SSL usage must be configured
+ on both the client and the server> before the connection
is made. If it is only configured on the server, the client may end up
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 sslmode> parameter to verify-full> or
verify-ca>, and providing the system with a root certificate to
- verify against. This is analogous to using a https>
+ verify against. This is analogous to using an https>
URL> for encrypted web browsing.
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
- certificates will be used for authentication, making it safe to specify this
+ certificates will be used for authentication, making it safe to specify that
only in the server configuration.
All
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
sslmode> values protect against, and what statement they make
about security and overhead:
The difference between verify-ca> and verify-full>
depends on the policy of the root
CA>. If a public
CA> is used, verify-ca> allows connections to a server
- that
somebody else> may have registered with the CA>
- to succeed. In this case, verify-full> should always be used. If
+ that
somebody else> may have registered with the CA>.
+ In this case, verify-full> should always be used. If
a local
CA> is used, or even a self-signed certificate, using
verify-ca> often provides enough protection.
The default value for sslmode> is prefer>. As is shown
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
- for backwards compatibility, and not recommended in secure deployments.
+ for backwards compatibility, and is not recommended in secure deployments.
|
~/.postgresql/root.crt>
trusted certificate authorities
- checks server certificate is signed by a trusted certificate
+ checks that server certificate is signed by a trusted certificate
authority