@@ -215,7 +215,7 @@ X509 * proxy_read_x509(const char *filen, bool bootstrap, std::string& msg) {
215
215
}
216
216
217
217
// return 0 un success
218
- int ssl_mkit (X509 **x509ca, X509 ** x509p, EVP_PKEY **pkeyp, int bits, int serial, int days, bool bootstrap, std::string& msg) {
218
+ int ssl_mkit (X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days, bool bootstrap, std::string& msg) {
219
219
X509 *x1;
220
220
X509 *x2;
221
221
EVP_PKEY *pk;
@@ -332,23 +332,18 @@ int ssl_mkit(X509 **x509ca, X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial
332
332
// during bootstrap we just call the reads
333
333
// if the read fails during bootstrap, proxysql immediately exists
334
334
pk = proxy_key_read (ssl_key_fp, bootstrap, msg);
335
- x1 = proxy_read_x509 (ssl_ca_fp, bootstrap, msg);
336
335
x2 = proxy_read_x509 (ssl_cert_fp, bootstrap, msg);
337
336
} else {
338
337
pk = proxy_key_read (ssl_key_fp, bootstrap, msg);
339
338
if (pk) {
340
- x1 = proxy_read_x509 (ssl_ca_fp, bootstrap, msg);
341
- if (x1) {
342
- x2 = proxy_read_x509 (ssl_cert_fp, bootstrap, msg);
343
- }
339
+ x2 = proxy_read_x509 (ssl_cert_fp, bootstrap, msg);
344
340
}
345
341
// note that this is only relevant during PROXYSQL RELOAD TLS
346
- if (pk == NULL || x1 == NULL || x2 == NULL ) {
342
+ if (pk == NULL || x2 == NULL ) {
347
343
return 1 ;
348
344
}
349
345
}
350
346
}
351
- *x509ca = x1;
352
347
*x509p = x2;
353
348
*pkeyp = pk;
354
349
@@ -377,7 +372,6 @@ int ssl_mkit(X509 **x509ca, X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial
377
372
int ProxySQL_create_or_load_TLS (bool bootstrap, std::string& msg) {
378
373
BIO *bio_err;
379
374
X509 *x509 = NULL ;
380
- X509 *x509ca = NULL ;
381
375
EVP_PKEY *pkey = NULL ;
382
376
383
377
int ret = 0 ;
@@ -386,7 +380,7 @@ int ProxySQL_create_or_load_TLS(bool bootstrap, std::string& msg) {
386
380
387
381
if (bootstrap == true ) {
388
382
// this is legacy code, when keys are loaded only during bootstrap
389
- if (ssl_mkit (&x509ca, & x509, &pkey, 2048 , 0 , 730 , true , msg) != 0 ) {
383
+ if (ssl_mkit (&x509, &pkey, 2048 , 0 , 730 , true , msg) != 0 ) {
390
384
proxy_error (" Unable to initialize SSL. Shutting down...\n " );
391
385
exit (EXIT_SUCCESS); // we exit gracefully to not be restarted
392
386
}
@@ -396,11 +390,6 @@ int ProxySQL_create_or_load_TLS(bool bootstrap, std::string& msg) {
396
390
proxy_error (" Unable to use SSL certificate. Shutting down...\n " );
397
391
exit (EXIT_SUCCESS); // we exit gracefully to not be restarted
398
392
}
399
- if ( SSL_CTX_add_extra_chain_cert (GloVars.global .ssl_ctx , x509ca) <= 0 ) {
400
- ERR_print_errors_fp (stderr);
401
- proxy_error (" Unable to use SSL CA chain. Shutting down...\n " );
402
- exit (EXIT_SUCCESS); // we exit gracefully to not be restarted
403
- }
404
393
if ( SSL_CTX_use_PrivateKey (GloVars.global .ssl_ctx , pkey) <= 0 ) {
405
394
ERR_print_errors_fp (stderr);
406
395
proxy_error (" Unable to use SSL key. Shutting down...\n " );
@@ -415,7 +404,7 @@ int ProxySQL_create_or_load_TLS(bool bootstrap, std::string& msg) {
415
404
416
405
// We set the locations for the certificates to be used for
417
406
// verifications purposes.
418
- if (!SSL_CTX_load_verify_locations (GloVars.global .ssl_ctx , ssl_ca_fp, ssl_ca_fp )) {
407
+ if (!SSL_CTX_load_verify_locations (GloVars.global .ssl_ctx , ssl_ca_fp, GloVars. datadir )) {
419
408
proxy_error (" Unable to load CA certificates location for verification. Shutting down\n " );
420
409
}
421
410
@@ -429,12 +418,11 @@ int ProxySQL_create_or_load_TLS(bool bootstrap, std::string& msg) {
429
418
} else {
430
419
// here we use global.tmp_ssl_ctx instead of global.ssl_ctx
431
420
// because we will try to swap at the end
432
- if (ssl_mkit (&x509ca, & x509, &pkey, 2048 , 0 , 730 , false , msg) == 0 ) { // 0 on success
421
+ if (ssl_mkit (&x509, &pkey, 2048 , 0 , 730 , false , msg) == 0 ) { // 0 on success
433
422
if (SSL_CTX_use_certificate (GloVars.global .tmp_ssl_ctx , x509) == 1 ) { // 1 on success
434
- if (SSL_CTX_add_extra_chain_cert (GloVars.global .tmp_ssl_ctx , x509ca) == 1 ) { // 1 on success
435
423
if (SSL_CTX_use_PrivateKey (GloVars.global .tmp_ssl_ctx , pkey) == 1 ) { // 1 on success
436
424
if (SSL_CTX_check_private_key (GloVars.global .tmp_ssl_ctx ) == 1 ) { // 1 on success
437
- if (SSL_CTX_load_verify_locations (GloVars.global .tmp_ssl_ctx , ssl_ca_fp, ssl_ca_fp ) == 1 ) { // 1 on success
425
+ if (SSL_CTX_load_verify_locations (GloVars.global .tmp_ssl_ctx , ssl_ca_fp, GloVars. datadir ) == 1 ) { // 1 on success
438
426
439
427
// take the mutex
440
428
std::lock_guard<std::mutex> lock (GloVars.global .ssl_mutex );
@@ -463,12 +451,6 @@ int ProxySQL_create_or_load_TLS(bool bootstrap, std::string& msg) {
463
451
msg = " Unable to use SSL key" ;
464
452
ret = 1 ;
465
453
}
466
- } else {
467
- ERR_print_errors_fp (stderr);
468
- proxy_error (" Unable to use SSL CA chain\n " );
469
- msg = " Unable to use SSL CA chain" ;
470
- ret = 1 ;
471
- }
472
454
} else {
473
455
ERR_print_errors_fp (stderr);
474
456
proxy_error (" Unable to use SSL certificate\n " );
0 commit comments