summaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-secure-common.h
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2018-01-27 13:47:52 -0500
committerPeter Eisentraut <peter_e@gmx.net>2018-01-30 22:56:24 -0500
commitf75a95915528646cbfaf238fb48b3ffa17969383 (patch)
tree39ae8490eadc1b2c965b569be2e43abe77ca1c49 /src/interfaces/libpq/fe-secure-common.h
parent38d485fdaa5739627b642303cc172acc1487b90a (diff)
downloadpostgresql-f75a95915528646cbfaf238fb48b3ffa17969383.tar.gz
Refactor client-side SSL certificate checking code
Separate the parts specific to the SSL library from the general logic. The previous code structure was open_client_SSL() calls verify_peer_name_matches_certificate() calls verify_peer_name_matches_certificate_name() calls wildcard_certificate_match() and was completely in fe-secure-openssl.c. The new structure is open_client_SSL() [openssl] calls pq_verify_peer_name_matches_certificate() [generic] calls pgtls_verify_peer_name_matches_certificate_guts() [openssl] calls openssl_verify_peer_name_matches_certificate_name() [openssl] calls pq_verify_peer_name_matches_certificate_name() [generic] calls wildcard_certificate_match() [generic] Move the generic functions into a new file fe-secure-common.c, so the calls generally go fe-connect.c -> fe-secure.c -> fe-secure-${impl}.c -> fe-secure-common.c, although there is a bit of back-and-forth between the last two. Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
Diffstat (limited to 'src/interfaces/libpq/fe-secure-common.h')
-rw-r--r--src/interfaces/libpq/fe-secure-common.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/interfaces/libpq/fe-secure-common.h b/src/interfaces/libpq/fe-secure-common.h
new file mode 100644
index 0000000000..980a58af25
--- /dev/null
+++ b/src/interfaces/libpq/fe-secure-common.h
@@ -0,0 +1,26 @@
+/*-------------------------------------------------------------------------
+ *
+ * fe-secure-common.h
+ *
+ * common implementation-independent SSL support code
+ *
+ * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * IDENTIFICATION
+ * src/interfaces/libpq/fe-secure-common.h
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#ifndef FE_SECURE_COMMON_H
+#define FE_SECURE_COMMON_H
+
+#include "libpq-fe.h"
+
+extern int pq_verify_peer_name_matches_certificate_name(PGconn *conn,
+ const char *namedata, size_t namelen,
+ char **store_name);
+extern bool pq_verify_peer_name_matches_certificate(PGconn *conn);
+
+#endif /* FE_SECURE_COMMON_H */