index 08a5a9c1f306184eced695ddd44669f61a9bd50e..4cbe64ceb58469200d0c2ee5a8df7eeb7c4176c8 100644 (file)
/*
* Select the mechanism to use. Pick SCRAM-SHA-256-PLUS over anything
- * else if a channel binding type is set. Pick SCRAM-SHA-256 if
- * nothing else has already been picked. If we add more mechanisms, a
- * more refined priority mechanism might become necessary.
+ * else if a channel binding type is set and if the client supports
+ * it. Pick SCRAM-SHA-256 if nothing else has already been picked. If
+ * we add more mechanisms, a more refined priority mechanism might
+ * become necessary.
*/
if (strcmp(mechanism_buf.data, SCRAM_SHA_256_PLUS_NAME) == 0)
{
if (conn->ssl_in_use)
+ {
+ /*
+ * The server has offered SCRAM-SHA-256-PLUS, which is only
+ * supported by the client if a hash of the peer certificate
+ * can be created.
+ */
+#ifdef HAVE_PGTLS_GET_PEER_CERTIFICATE_HASH
selected_mechanism = SCRAM_SHA_256_PLUS_NAME;
+#endif
+ }
else
{
/*