4dc6355210 provided a way for libraries and clients to modify how libpq
handles client certificate passphrases, by installing a hook. However,
these routines are quite specific to how OpenSSL works, so it's
misleading and not future-proof to have these names not refer to OpenSSL.
Change all the names to add "_OpenSSL" after "Hook", and fix the docs
accordingly.
Author: Daniel Gustafsson
Discussion: https://postgr.es/m/
981DE552 -E399-45C2-9F60-
3F0E3770CC61 @yesql.se
-
PQsetSSLKeyPassHook PQsetSSLKeyPassHook
+
PQsetSSLKeyPassHook_OpenSSL PQsetSSLKeyPassHook_OpenSSL
- PQsetSSLKeyPassHook lets an application override
+ PQsetSSLKeyPassHook_OpenSSL lets an application override
libpq 's default
handling of encrypted client certificate key files using
or interactive prompting.
-void PQsetSSLKeyPassHook(PQsslKeyPassHook _type hook);
+void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL _type hook);
The application passes a pointer to a callback function with signature:
int callback_fn(char *buf, int size, PGconn *conn);
which libpq will then call instead of
- its default PQdefaultSSLKeyPassHook handler. The callback
+ its default PQdefaultSSLKeyPassHook_OpenSSL handler. The callback
should determine the password for the key and copy it to result-buffer
buf of size size . The string in
buf must be null-terminated. The callback must return the length of
the password stored in buf excluding the null terminator.
On failure, the callback should set buf[0] = '\0' and return 0.
- See PQdefaultSSLKeyPassHook in libpq 's
+ See PQdefaultSSLKeyPassHook_OpenSSL in libpq 's
source code for an example.
The app callback may choose to delegate unhandled cases to
- PQdefaultSSLKeyPassHook ,
+ PQdefaultSSLKeyPassHook_OpenSSL ,
or call it first and try something else if it returns 0, or completely override it.
if none has been set.
-PQsslKeyPassHook_type PQgetSSLKeyPassHook(void);
+PQsslKeyPassHook_OpenSSL_ type PQgetSSLKeyPassHook(void);
#endif
#endif /* ENABLE_THREAD_SAFETY */
-static PQsslKeyPassHook_type PQsslKeyPassHook = NULL;
+static PQsslKeyPassHook_OpenSSL_ type PQsslKeyPassHook = NULL;
static int ssl_protocol_version_to_openssl(const char *protocol);
/* ------------------------------------------------------------ */
* prevent openssl from ever prompting on stdin.
*/
int
-PQdefaultSSLKeyPassHook(char *buf, int size, PGconn *conn)
+PQdefaultSSLKeyPassHook_OpenSSL (char *buf, int size, PGconn *conn)
{
if (conn->sslpassword)
{
}
}
-PQsslKeyPassHook_type
+PQsslKeyPassHook_OpenSSL_ type
PQgetSSLKeyPassHook(void)
{
return PQsslKeyPassHook;
}
void
-PQsetSSLKeyPassHook(PQsslKeyPassHook _type hook)
+PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL _type hook)
{
PQsslKeyPassHook = hook;
}
if (PQsslKeyPassHook)
return PQsslKeyPassHook(buf, size, conn);
else
- return PQdefaultSSLKeyPassHook(buf, size, conn);
+ return PQdefaultSSLKeyPassHook_OpenSSL (buf, size, conn);
}
/*
return result;
}
-PQsslKeyPassHook_type
-PQgetSSLKeyPassHook(void)
+PQsslKeyPassHook_OpenSSL_ type
+PQgetSSLKeyPassHook_OpenSSL (void)
{
return NULL;
}
void
-PQsetSSLKeyPassHook(PQsslKeyPassHook _type hook)
+PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL _type hook)
{
return;
}
int
-PQdefaultSSLKeyPassHook(char *buf, int size, PGconn *conn)
+PQdefaultSSLKeyPassHook_OpenSSL (char *buf, int size, PGconn *conn)
{
return 0;
}
extern const char *pg_encoding_to_char(int encoding);
extern int pg_valid_server_encoding_id(int encoding);
-/* == in fe-secure-openssl.c === */
+/* === in fe-secure-openssl.c === */
/* Support for overriding sslpassword handling with a callback. */
-typedef int (*PQsslKeyPassHook_type) (char *buf, int size, PGconn *conn);
-extern PQsslKeyPassHook_type PQgetSSLKeyPassHook(void);
-extern void PQsetSSLKeyPassHook(PQsslKeyPassHook _type hook);
-extern int PQdefaultSSLKeyPassHook(char *buf, int size, PGconn *conn);
+typedef int (*PQsslKeyPassHook_OpenSSL_ type) (char *buf, int size, PGconn *conn);
+extern PQsslKeyPassHook_OpenSSL_ type PQgetSSLKeyPassHook(void);
+extern void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL _type hook);
+extern int PQdefaultSSLKeyPassHook_OpenSSL (char *buf, int size, PGconn *conn);
#ifdef __cplusplus
}