diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-09-12 17:12:11 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-09-12 17:17:05 +0300 |
commit | acd08d764a361dcebd346227281ff0ca62b60936 (patch) | |
tree | 7061cbd18b063731d13646ca32ae4d9b39a4f78e /src/interfaces/libpq/fe-misc.c | |
parent | 774a78ffe47557313d69c2b27e7d61480a3b9d1f (diff) |
Support Subject Alternative Names in SSL server certificates.
This patch makes libpq check the server's hostname against DNS names listed
in the X509 subjectAltName extension field in the server certificate. This
allows the same certificate to be used for multiple domain names. If there
are no SANs in the certificate, the Common Name field is used, like before
this patch. If both are given, the Common Name is ignored. That is a bit
surprising, but that's the behavior mandated by the relevant RFCs, and it's
also what the common web browsers do.
This also adds a libpq_ngettext helper macro to allow plural messages to be
translated in libpq. Apparently this happened to be the first plural message
in libpq, so it was not needed before.
Alexey Klyukin, with some kibitzing by me.
Diffstat (limited to 'src/interfaces/libpq/fe-misc.c')
-rw-r--r-- | src/interfaces/libpq/fe-misc.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index fc930bd05b8..44f7d039784 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -1210,14 +1210,14 @@ PQenv2encoding(void) #ifdef ENABLE_NLS -char * -libpq_gettext(const char *msgid) +static void +libpq_binddomain() { static bool already_bound = false; if (!already_bound) { - /* dgettext() preserves errno, but bindtextdomain() doesn't */ + /* bindtextdomain() does not preserve errno */ #ifdef WIN32 int save_errno = GetLastError(); #else @@ -1237,8 +1237,20 @@ libpq_gettext(const char *msgid) errno = save_errno; #endif } +} +char * +libpq_gettext(const char *msgid) +{ + libpq_binddomain(); return dgettext(PG_TEXTDOMAIN("libpq"), msgid); } +char * +libpq_ngettext(const char *msgid, const char *msgid_plural, unsigned long n) +{ + libpq_binddomain(); + return dngettext(PG_TEXTDOMAIN("libpq"), msgid, msgid_plural, n); +} + #endif /* ENABLE_NLS */ |