@@ -198,7 +198,12 @@ be_tls_init(bool isServerStart)
198
198
199
199
if (ssl_ver == -1 )
200
200
goto error ;
201
- SSL_CTX_set_min_proto_version (context , ssl_ver );
201
+ if (!SSL_CTX_set_min_proto_version (context , ssl_ver ))
202
+ {
203
+ ereport (isServerStart ? FATAL : LOG ,
204
+ (errmsg ("could not set minimum SSL protocol version" )));
205
+ goto error ;
206
+ }
202
207
}
203
208
204
209
if (ssl_max_protocol_version )
@@ -209,7 +214,12 @@ be_tls_init(bool isServerStart)
209
214
210
215
if (ssl_ver == -1 )
211
216
goto error ;
212
- SSL_CTX_set_max_proto_version (context , ssl_ver );
217
+ if (!SSL_CTX_set_max_proto_version (context , ssl_ver ))
218
+ {
219
+ ereport (isServerStart ? FATAL : LOG ,
220
+ (errmsg ("could not set maximum SSL protocol version" )));
221
+ goto error ;
222
+ }
213
223
}
214
224
215
225
/* disallow SSL session tickets */
@@ -1326,13 +1336,30 @@ SSL_CTX_set_min_proto_version(SSL_CTX *ctx, int version)
1326
1336
1327
1337
if (version > TLS1_VERSION )
1328
1338
ssl_options |= SSL_OP_NO_TLSv1 ;
1339
+ /*
1340
+ * Some OpenSSL versions define TLS*_VERSION macros but not the
1341
+ * corresponding SSL_OP_NO_* macro, so in those cases we have to return
1342
+ * unsuccessfully here.
1343
+ */
1329
1344
#ifdef TLS1_1_VERSION
1330
1345
if (version > TLS1_1_VERSION )
1346
+ {
1347
+ #ifdef SSL_OP_NO_TLSv1_1
1331
1348
ssl_options |= SSL_OP_NO_TLSv1_1 ;
1349
+ #else
1350
+ return 0 ;
1351
+ #endif
1352
+ }
1332
1353
#endif
1333
1354
#ifdef TLS1_2_VERSION
1334
1355
if (version > TLS1_2_VERSION )
1356
+ {
1357
+ #ifdef SSL_OP_NO_TLSv1_2
1335
1358
ssl_options |= SSL_OP_NO_TLSv1_2 ;
1359
+ #else
1360
+ return 0 ;
1361
+ #endif
1362
+ }
1336
1363
#endif
1337
1364
1338
1365
SSL_CTX_set_options (ctx , ssl_options );
@@ -1347,13 +1374,30 @@ SSL_CTX_set_max_proto_version(SSL_CTX *ctx, int version)
1347
1374
1348
1375
AssertArg (version != 0 );
1349
1376
1377
+ /*
1378
+ * Some OpenSSL versions define TLS*_VERSION macros but not the
1379
+ * corresponding SSL_OP_NO_* macro, so in those cases we have to return
1380
+ * unsuccessfully here.
1381
+ */
1350
1382
#ifdef TLS1_1_VERSION
1351
1383
if (version < TLS1_1_VERSION )
1384
+ {
1385
+ #ifdef SSL_OP_NO_TLSv1_1
1352
1386
ssl_options |= SSL_OP_NO_TLSv1_1 ;
1387
+ #else
1388
+ return 0 ;
1389
+ #endif
1390
+ }
1353
1391
#endif
1354
1392
#ifdef TLS1_2_VERSION
1355
1393
if (version < TLS1_2_VERSION )
1394
+ {
1395
+ #ifdef SSL_OP_NO_TLSv1_2
1356
1396
ssl_options |= SSL_OP_NO_TLSv1_2 ;
1397
+ #else
1398
+ return 0 ;
1399
+ #endif
1400
+ }
1357
1401
#endif
1358
1402
1359
1403
SSL_CTX_set_options (ctx , ssl_options );
0 commit comments