@@ -67,7 +67,8 @@ static bool SSL_initialized = false;
67
67
static bool dummy_ssl_passwd_cb_called = false;
68
68
static bool ssl_is_server_start ;
69
69
70
- static int ssl_protocol_version_to_openssl (int v , const char * guc_name );
70
+ static int ssl_protocol_version_to_openssl (int v , const char * guc_name ,
71
+ int loglevel );
71
72
#ifndef SSL_CTX_set_min_proto_version
72
73
static int SSL_CTX_set_min_proto_version (SSL_CTX * ctx , int version );
73
74
static int SSL_CTX_set_max_proto_version (SSL_CTX * ctx , int version );
@@ -190,13 +191,24 @@ be_tls_init(bool isServerStart)
190
191
}
191
192
192
193
if (ssl_min_protocol_version )
193
- SSL_CTX_set_min_proto_version (context ,
194
- ssl_protocol_version_to_openssl (ssl_min_protocol_version ,
195
- "ssl_min_protocol_version" ));
194
+ {
195
+ int ssl_ver = ssl_protocol_version_to_openssl (ssl_min_protocol_version ,
196
+ "ssl_min_protocol_version" ,
197
+ isServerStart ? FATAL : LOG );
198
+ if (ssl_ver == -1 )
199
+ goto error ;
200
+ SSL_CTX_set_min_proto_version (context , ssl_ver );
201
+ }
202
+
196
203
if (ssl_max_protocol_version )
197
- SSL_CTX_set_max_proto_version (context ,
198
- ssl_protocol_version_to_openssl (ssl_max_protocol_version ,
199
- "ssl_max_protocol_version" ));
204
+ {
205
+ int ssl_ver = ssl_protocol_version_to_openssl (ssl_max_protocol_version ,
206
+ "ssl_max_protocol_version" ,
207
+ isServerStart ? FATAL : LOG );
208
+ if (ssl_ver == -1 )
209
+ goto error ;
210
+ SSL_CTX_set_max_proto_version (context , ssl_ver );
211
+ }
200
212
201
213
/* disallow SSL session tickets */
202
214
#ifdef SSL_OP_NO_TICKET /* added in OpenSSL 0.9.8f */
@@ -1258,11 +1270,12 @@ X509_NAME_to_cstring(X509_NAME *name)
1258
1270
* guc.c independent of OpenSSL availability and version.
1259
1271
*
1260
1272
* If a version is passed that is not supported by the current OpenSSL
1261
- * version, then we throw an error, so that subsequent code can assume it's
1262
- * working with a supported version.
1273
+ * version, then we log with the given loglevel and return (if we return) -1.
1274
+ * If a nonnegative value is returned, subsequent code can assume it's working
1275
+ * with a supported version.
1263
1276
*/
1264
1277
static int
1265
- ssl_protocol_version_to_openssl (int v , const char * guc_name )
1278
+ ssl_protocol_version_to_openssl (int v , const char * guc_name , int loglevel )
1266
1279
{
1267
1280
switch (v )
1268
1281
{
@@ -1292,7 +1305,7 @@ ssl_protocol_version_to_openssl(int v, const char *guc_name)
1292
1305
1293
1306
error :
1294
1307
pg_attribute_unused ();
1295
- ereport (ERROR ,
1308
+ ereport (loglevel ,
1296
1309
(errmsg ("%s setting %s not supported by this build" ,
1297
1310
guc_name ,
1298
1311
GetConfigOption (guc_name , false, false))));
0 commit comments