Skip to content

Commit 6d16902

Browse files
committed
Add ssl_cipher() and ssl_version() functions to contrib/sslinfo.
Review by Dave Page.
1 parent 9b6b0b0 commit 6d16902

File tree

4 files changed

+66
-4
lines changed

4 files changed

+66
-4
lines changed

contrib/sslinfo/sslinfo.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Written by Victor B. Wagner <vitus@cryptocom.ru>, Cryptocom LTD
55
* This file is distributed under BSD-style license.
66
*
7-
* $PostgreSQL: pgsql/contrib/sslinfo/sslinfo.c,v 1.8 2008/11/10 14:57:38 tgl Exp $
7+
* $PostgreSQL: pgsql/contrib/sslinfo/sslinfo.c,v 1.9 2010/07/27 23:43:42 rhaas Exp $
88
*/
99

1010
#include "postgres.h"
@@ -23,6 +23,8 @@ PG_MODULE_MAGIC;
2323

2424

2525
Datum ssl_is_used(PG_FUNCTION_ARGS);
26+
Datum ssl_version(PG_FUNCTION_ARGS);
27+
Datum ssl_cipher(PG_FUNCTION_ARGS);
2628
Datum ssl_client_cert_present(PG_FUNCTION_ARGS);
2729
Datum ssl_client_serial(PG_FUNCTION_ARGS);
2830
Datum ssl_client_dn_field(PG_FUNCTION_ARGS);
@@ -48,6 +50,32 @@ ssl_is_used(PG_FUNCTION_ARGS)
4850
}
4951

5052

53+
/*
54+
* Returns SSL cipher currently in use.
55+
*/
56+
PG_FUNCTION_INFO_V1(ssl_version);
57+
Datum
58+
ssl_version(PG_FUNCTION_ARGS)
59+
{
60+
if (MyProcPort->ssl == NULL)
61+
PG_RETURN_NULL();
62+
PG_RETURN_TEXT_P(cstring_to_text(SSL_get_version(MyProcPort->ssl)));
63+
}
64+
65+
66+
/*
67+
* Returns SSL cipher currently in use.
68+
*/
69+
PG_FUNCTION_INFO_V1(ssl_cipher);
70+
Datum
71+
ssl_cipher(PG_FUNCTION_ARGS)
72+
{
73+
if (MyProcPort->ssl == NULL)
74+
PG_RETURN_NULL();
75+
PG_RETURN_TEXT_P(cstring_to_text(SSL_get_cipher(MyProcPort->ssl)));
76+
}
77+
78+
5179
/*
5280
* Indicates whether current client have provided a certificate
5381
*

contrib/sslinfo/sslinfo.sql.in

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/contrib/sslinfo/sslinfo.sql.in,v 1.4 2007/11/13 04:24:29 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/contrib/sslinfo/sslinfo.sql.in,v 1.5 2010/07/27 23:43:42 rhaas Exp $ */
22

33
-- Adjust this setting to control where the objects get created.
44
SET search_path = public;
@@ -11,6 +11,14 @@ CREATE OR REPLACE FUNCTION ssl_is_used() RETURNS boolean
1111
AS 'MODULE_PATHNAME', 'ssl_is_used'
1212
LANGUAGE C STRICT;
1313

14+
CREATE OR REPLACE FUNCTION ssl_version() RETURNS text
15+
AS 'MODULE_PATHNAME', 'ssl_version'
16+
LANGUAGE C STRICT;
17+
18+
CREATE OR REPLACE FUNCTION ssl_cipher() RETURNS text
19+
AS 'MODULE_PATHNAME', 'ssl_cipher'
20+
LANGUAGE C STRICT;
21+
1422
CREATE OR REPLACE FUNCTION ssl_client_cert_present() RETURNS boolean
1523
AS 'MODULE_PATHNAME', 'ssl_client_cert_present'
1624
LANGUAGE C STRICT;

contrib/sslinfo/uninstall_sslinfo.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
/* $PostgreSQL: pgsql/contrib/sslinfo/uninstall_sslinfo.sql,v 1.3 2007/11/13 04:24:29 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/contrib/sslinfo/uninstall_sslinfo.sql,v 1.4 2010/07/27 23:43:42 rhaas Exp $ */
22

33
-- Adjust this setting to control where the objects get dropped.
44
SET search_path = public;
55

66
DROP FUNCTION ssl_client_serial();
77
DROP FUNCTION ssl_is_used();
8+
DROP FUNCTION ssl_cipher();
9+
DROP FUNCTION ssl_version();
810
DROP FUNCTION ssl_client_cert_present();
911
DROP FUNCTION ssl_client_dn_field(text);
1012
DROP FUNCTION ssl_issuer_field(text);

doc/src/sgml/sslinfo.sgml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/sslinfo.sgml,v 1.3 2007/12/06 04:12:10 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/sslinfo.sgml,v 1.4 2010/07/27 23:43:42 rhaas Exp $ -->
22

33
<sect1 id="sslinfo">
44
<title>sslinfo</title>
@@ -35,6 +35,30 @@ ssl_is_used() returns boolean
3535
</listitem>
3636
</varlistentry>
3737

38+
<varlistentry>
39+
<term><function>
40+
ssl_version() returns text
41+
</function></term>
42+
<listitem>
43+
<para>
44+
Returns the name of the protocol used for the SSL connection (e.g. SSLv2,
45+
SSLv3, or TLSv1).
46+
</para>
47+
</listitem>
48+
</varlistentry>
49+
50+
<varlistentry>
51+
<term><function>
52+
ssl_cipher() returns text
53+
</function></term>
54+
<listitem>
55+
<para>
56+
Returns the name of the cipher used for the SSL connection
57+
(e.g. DHE-RSA-AES256-SHA).
58+
</para>
59+
</listitem>
60+
</varlistentry>
61+
3862
<varlistentry>
3963
<term><function>
4064
ssl_client_cert_present() returns boolean

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy