6 <indexterm zone=
"sslinfo">
7 <primary>sslinfo
</primary>
11 The
<filename>sslinfo<
/> module provides information about the SSL
12 certificate that the current client provided when connecting to
13 <productname>PostgreSQL<
/>. The module is useless (most functions
14 will return NULL) if the current connection does not use SSL.
18 This extension won't build at all unless the installation was
19 configured with
<literal>--with-openssl<
/>.
23 <title>Functions Provided
</title>
28 ssl_is_used() returns boolean
32 Returns TRUE if current connection to server uses SSL, and FALSE
40 ssl_client_cert_present() returns boolean
44 Returns TRUE if current client has presented a valid SSL client
45 certificate to the server, and FALSE otherwise. (The server
46 might or might not be configured to require a client certificate.)
53 ssl_client_serial() returns numeric
57 Returns serial number of current client certificate. The combination of
58 certificate serial number and certificate issuer is guaranteed to
59 uniquely identify a certificate (but not its owner
— the owner
60 ought to regularly change his keys, and get new certificates from the
65 So, if you run your own CA and allow only certificates from this CA to
66 be accepted by the server, the serial number is the most reliable (albeit
67 not very mnemonic) means to identify a user.
74 ssl_client_dn() returns text
78 Returns the full subject of the current client certificate, converting
79 character data into the current database encoding. It is assumed that
80 if you use non-ASCII characters in the certificate names, your
81 database is able to represent these characters, too. If your database
82 uses the SQL_ASCII encoding, non-ASCII characters in the name will be
83 represented as UTF-
8 sequences.
87 The result looks like
<literal>/CN=Somebody /C=Some country/O=Some organization<
/>.
94 ssl_issuer_dn() returns text
98 Returns the full issuer name of the current client certificate, converting
99 character data into the current database encoding. Encoding conversions
100 are handled the same as for
<function>ssl_client_dn<
/>.
103 The combination of the return value of this function with the
104 certificate serial number uniquely identifies the certificate.
107 This function is really useful only if you have more than one trusted CA
108 certificate in your server's
<filename>root.crt<
/> file, or if this CA
109 has issued some intermediate certificate authority certificates.
116 ssl_client_dn_field(fieldname text) returns text
120 This function returns the value of the specified field in the
121 certificate subject, or NULL if the field is not present.
122 Field names are string constants that are
123 converted into ASN1 object identifiers using the OpenSSL object
124 database. The following values are acceptable:
127 commonName (alias CN)
131 countryName (alias C)
132 localityName (alias L)
133 stateOrProvinceName (alias ST)
134 organizationName (alias O)
135 organizationUnitName (alias OU)
150 All of these fields are optional, except
<structfield>commonName<
/>.
152 entirely on your CA's policy which of them would be included and which
153 wouldn't. The meaning of these fields, however, is strictly defined by
154 the X
.500 and X
.509 standards, so you cannot just assign arbitrary
162 ssl_issuer_field(fieldname text) returns text
166 Same as
<function>ssl_client_dn_field<
/>, but for the certificate issuer
167 rather than the certificate subject.
175 <title>Author
</title>
178 Victor Wagner
<email>vitus@cryptocom.ru
</email>, Cryptocom LTD
182 E-Mail of Cryptocom OpenSSL development group:
183 <email>openssl@cryptocom.ru
</email>