mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
Support channel binding 'tls-unique' in SCRAM
This is the basic feature set using OpenSSL to support the feature. In order to allow the frontend and the backend to fetch the sent and expected TLS Finished messages, a PG-like API is added to be able to make the interface pluggable for other SSL implementations. This commit also adds a infrastructure to facilitate the addition of future channel binding types as well as libpq parameters to control the SASL mechanism names and channel binding names. Those will be added by upcoming commits. Some tests are added to the SSL test suite to test SCRAM authentication with channel binding. Author: Michael Paquier <michael@paquier.xyz> Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
This commit is contained in:
@ -393,6 +393,33 @@ pgtls_write(PGconn *conn, const void *ptr, size_t len)
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the TLS finish message sent during last handshake
|
||||
*
|
||||
* This information is useful for callers doing channel binding during
|
||||
* authentication.
|
||||
*/
|
||||
char *
|
||||
pgtls_get_finished(PGconn *conn, size_t *len)
|
||||
{
|
||||
char dummy[1];
|
||||
char *result;
|
||||
|
||||
/*
|
||||
* OpenSSL does not offer an API to get directly the length of the TLS
|
||||
* Finished message sent, so first do a dummy call to grab this
|
||||
* information and then do an allocation with the correct size.
|
||||
*/
|
||||
*len = SSL_get_finished(conn->ssl, dummy, sizeof(dummy));
|
||||
result = malloc(*len);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
(void) SSL_get_finished(conn->ssl, result, *len);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* OpenSSL specific code */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
Reference in New Issue
Block a user