diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/usr.bin/openssl/x509.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/usr.bin/openssl/x509.c b/src/usr.bin/openssl/x509.c index 3102be9ba3..5ee478b050 100644 --- a/src/usr.bin/openssl/x509.c +++ b/src/usr.bin/openssl/x509.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: x509.c,v 1.24 2021/08/29 19:56:40 schwarze Exp $ */ | 1 | /* $OpenBSD: x509.c,v 1.25 2021/10/23 15:44:39 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -846,16 +846,6 @@ x509_main(int argc, char **argv) | |||
| 846 | ERR_print_errors(bio_err); | 846 | ERR_print_errors(bio_err); |
| 847 | goto end; | 847 | goto end; |
| 848 | } | 848 | } |
| 849 | if ((req->req_info == NULL) || | ||
| 850 | (req->req_info->pubkey == NULL) || | ||
| 851 | (req->req_info->pubkey->public_key == NULL) || | ||
| 852 | (req->req_info->pubkey->public_key->data == NULL)) { | ||
| 853 | BIO_printf(bio_err, | ||
| 854 | "The certificate request appears to corrupted\n"); | ||
| 855 | BIO_printf(bio_err, | ||
| 856 | "It does not contain a public key\n"); | ||
| 857 | goto end; | ||
| 858 | } | ||
| 859 | if ((pkey = X509_REQ_get_pubkey(req)) == NULL) { | 849 | if ((pkey = X509_REQ_get_pubkey(req)) == NULL) { |
| 860 | BIO_printf(bio_err, "error unpacking public key\n"); | 850 | BIO_printf(bio_err, "error unpacking public key\n"); |
| 861 | goto end; | 851 | goto end; |
| @@ -892,9 +882,9 @@ x509_main(int argc, char **argv) | |||
| 892 | } else if (!X509_set_serialNumber(x, x509_config.sno)) | 882 | } else if (!X509_set_serialNumber(x, x509_config.sno)) |
| 893 | goto end; | 883 | goto end; |
| 894 | 884 | ||
| 895 | if (!X509_set_issuer_name(x, req->req_info->subject)) | 885 | if (!X509_set_issuer_name(x, X509_REQ_get_subject_name(req))) |
| 896 | goto end; | 886 | goto end; |
| 897 | if (!X509_set_subject_name(x, req->req_info->subject)) | 887 | if (!X509_set_subject_name(x, X509_REQ_get_subject_name(req))) |
| 898 | goto end; | 888 | goto end; |
| 899 | 889 | ||
| 900 | if (X509_gmtime_adj(X509_get_notBefore(x), 0) == NULL) | 890 | if (X509_gmtime_adj(X509_get_notBefore(x), 0) == NULL) |
| @@ -1403,7 +1393,7 @@ x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest, X509 *x, | |||
| 1403 | { | 1393 | { |
| 1404 | int ret = 0; | 1394 | int ret = 0; |
| 1405 | ASN1_INTEGER *bs = NULL; | 1395 | ASN1_INTEGER *bs = NULL; |
| 1406 | X509_STORE_CTX xsc; | 1396 | X509_STORE_CTX *xsc = NULL; |
| 1407 | EVP_PKEY *upkey; | 1397 | EVP_PKEY *upkey; |
| 1408 | 1398 | ||
| 1409 | upkey = X509_get_pubkey(xca); | 1399 | upkey = X509_get_pubkey(xca); |
| @@ -1412,7 +1402,9 @@ x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest, X509 *x, | |||
| 1412 | EVP_PKEY_copy_parameters(upkey, pkey); | 1402 | EVP_PKEY_copy_parameters(upkey, pkey); |
| 1413 | EVP_PKEY_free(upkey); | 1403 | EVP_PKEY_free(upkey); |
| 1414 | 1404 | ||
| 1415 | if (!X509_STORE_CTX_init(&xsc, ctx, x, NULL)) { | 1405 | if ((xsc = X509_STORE_CTX_new()) == NULL) |
| 1406 | goto end; | ||
| 1407 | if (!X509_STORE_CTX_init(xsc, ctx, x, NULL)) { | ||
| 1416 | BIO_printf(bio_err, "Error initialising X509 store\n"); | 1408 | BIO_printf(bio_err, "Error initialising X509 store\n"); |
| 1417 | goto end; | 1409 | goto end; |
| 1418 | } | 1410 | } |
| @@ -1427,9 +1419,9 @@ x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest, X509 *x, | |||
| 1427 | * NOTE: this certificate can/should be self signed, unless it was a | 1419 | * NOTE: this certificate can/should be self signed, unless it was a |
| 1428 | * certificate request in which case it is not. | 1420 | * certificate request in which case it is not. |
| 1429 | */ | 1421 | */ |
| 1430 | X509_STORE_CTX_set_cert(&xsc, x); | 1422 | X509_STORE_CTX_set_cert(xsc, x); |
| 1431 | X509_STORE_CTX_set_flags(&xsc, X509_V_FLAG_CHECK_SS_SIGNATURE); | 1423 | X509_STORE_CTX_set_flags(xsc, X509_V_FLAG_CHECK_SS_SIGNATURE); |
| 1432 | if (!x509_config.reqfile && X509_verify_cert(&xsc) <= 0) | 1424 | if (!x509_config.reqfile && X509_verify_cert(xsc) <= 0) |
| 1433 | goto end; | 1425 | goto end; |
| 1434 | 1426 | ||
| 1435 | if (!X509_check_private_key(xca, pkey)) { | 1427 | if (!X509_check_private_key(xca, pkey)) { |
| @@ -1469,7 +1461,7 @@ x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest, X509 *x, | |||
| 1469 | 1461 | ||
| 1470 | ret = 1; | 1462 | ret = 1; |
| 1471 | end: | 1463 | end: |
| 1472 | X509_STORE_CTX_cleanup(&xsc); | 1464 | X509_STORE_CTX_free(xsc); |
| 1473 | if (!ret) | 1465 | if (!ret) |
| 1474 | ERR_print_errors(bio_err); | 1466 | ERR_print_errors(bio_err); |
| 1475 | if (sno == NULL) | 1467 | if (sno == NULL) |
