diff options
-rw-r--r-- | src/usr.bin/openssl/apps.c | 43 | ||||
-rw-r--r-- | src/usr.bin/openssl/apps.h | 3 | ||||
-rw-r--r-- | src/usr.bin/openssl/cms.c | 24 | ||||
-rw-r--r-- | src/usr.bin/openssl/s_cb.c | 5 | ||||
-rw-r--r-- | src/usr.bin/openssl/smime.c | 21 | ||||
-rw-r--r-- | src/usr.bin/openssl/verify.c | 5 |
6 files changed, 6 insertions, 95 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c index fd13371f5d..592a68980a 100644 --- a/src/usr.bin/openssl/apps.c +++ b/src/usr.bin/openssl/apps.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: apps.c,v 1.62 2022/01/10 12:17:49 tb Exp $ */ | 1 | /* $OpenBSD: apps.c,v 1.63 2023/04/14 15:27:13 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -1951,47 +1951,6 @@ pkey_ctrl_string(EVP_PKEY_CTX *ctx, char *value) | |||
1951 | return rv; | 1951 | return rv; |
1952 | } | 1952 | } |
1953 | 1953 | ||
1954 | static void | ||
1955 | nodes_print(BIO *out, const char *name, STACK_OF(X509_POLICY_NODE) *nodes) | ||
1956 | { | ||
1957 | X509_POLICY_NODE *node; | ||
1958 | int i; | ||
1959 | |||
1960 | BIO_printf(out, "%s Policies:", name); | ||
1961 | if (nodes) { | ||
1962 | BIO_puts(out, "\n"); | ||
1963 | for (i = 0; i < sk_X509_POLICY_NODE_num(nodes); i++) { | ||
1964 | node = sk_X509_POLICY_NODE_value(nodes, i); | ||
1965 | X509_POLICY_NODE_print(out, node, 2); | ||
1966 | } | ||
1967 | } else | ||
1968 | BIO_puts(out, " <empty>\n"); | ||
1969 | } | ||
1970 | |||
1971 | void | ||
1972 | policies_print(BIO *out, X509_STORE_CTX *ctx) | ||
1973 | { | ||
1974 | X509_POLICY_TREE *tree; | ||
1975 | int explicit_policy; | ||
1976 | int free_out = 0; | ||
1977 | |||
1978 | if (out == NULL) { | ||
1979 | out = BIO_new_fp(stderr, BIO_NOCLOSE); | ||
1980 | free_out = 1; | ||
1981 | } | ||
1982 | tree = X509_STORE_CTX_get0_policy_tree(ctx); | ||
1983 | explicit_policy = X509_STORE_CTX_get_explicit_policy(ctx); | ||
1984 | |||
1985 | BIO_printf(out, "Require explicit Policy: %s\n", | ||
1986 | explicit_policy ? "True" : "False"); | ||
1987 | |||
1988 | nodes_print(out, "Authority", X509_policy_tree_get0_policies(tree)); | ||
1989 | nodes_print(out, "User", X509_policy_tree_get0_user_policies(tree)); | ||
1990 | |||
1991 | if (free_out) | ||
1992 | BIO_free(out); | ||
1993 | } | ||
1994 | |||
1995 | /* | 1954 | /* |
1996 | * next_protos_parse parses a comma separated list of strings into a string | 1955 | * next_protos_parse parses a comma separated list of strings into a string |
1997 | * in a format suitable for passing to SSL_CTX_set_next_protos_advertised. | 1956 | * in a format suitable for passing to SSL_CTX_set_next_protos_advertised. |
diff --git a/src/usr.bin/openssl/apps.h b/src/usr.bin/openssl/apps.h index f4fa5361a7..82e0662c88 100644 --- a/src/usr.bin/openssl/apps.h +++ b/src/usr.bin/openssl/apps.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: apps.h,v 1.31 2022/01/10 12:17:49 tb Exp $ */ | 1 | /* $OpenBSD: apps.h,v 1.32 2023/04/14 15:27:13 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 | * |
@@ -237,7 +237,6 @@ int parse_yesno(const char *str, int def); | |||
237 | X509_NAME *parse_name(char *str, long chtype, int multirdn); | 237 | X509_NAME *parse_name(char *str, long chtype, int multirdn); |
238 | int args_verify(char ***pargs, int *pargc, int *badarg, BIO *err, | 238 | int args_verify(char ***pargs, int *pargc, int *badarg, BIO *err, |
239 | X509_VERIFY_PARAM **pm); | 239 | X509_VERIFY_PARAM **pm); |
240 | void policies_print(BIO *out, X509_STORE_CTX *ctx); | ||
241 | int bio_to_mem(unsigned char **out, int maxlen, BIO *in); | 240 | int bio_to_mem(unsigned char **out, int maxlen, BIO *in); |
242 | int pkey_ctrl_string(EVP_PKEY_CTX *ctx, char *value); | 241 | int pkey_ctrl_string(EVP_PKEY_CTX *ctx, char *value); |
243 | int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx, const char *algname, | 242 | int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx, const char *algname, |
diff --git a/src/usr.bin/openssl/cms.c b/src/usr.bin/openssl/cms.c index 0ddf26e5a7..121a413a21 100644 --- a/src/usr.bin/openssl/cms.c +++ b/src/usr.bin/openssl/cms.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cms.c,v 1.33 2023/03/06 14:32:05 tb Exp $ */ | 1 | /* $OpenBSD: cms.c,v 1.34 2023/04/14 15:27:13 tb Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project. | 3 | * project. |
4 | */ | 4 | */ |
@@ -69,7 +69,6 @@ | |||
69 | #include <openssl/cms.h> | 69 | #include <openssl/cms.h> |
70 | 70 | ||
71 | static int save_certs(char *signerfile, STACK_OF(X509) *signers); | 71 | static int save_certs(char *signerfile, STACK_OF(X509) *signers); |
72 | static int cms_cb(int ok, X509_STORE_CTX *ctx); | ||
73 | static void receipt_request_print(BIO *out, CMS_ContentInfo *cms); | 72 | static void receipt_request_print(BIO *out, CMS_ContentInfo *cms); |
74 | static CMS_ReceiptRequest *make_receipt_request( | 73 | static CMS_ReceiptRequest *make_receipt_request( |
75 | STACK_OF(OPENSSL_STRING) *rr_to, int rr_allorfirst, | 74 | STACK_OF(OPENSSL_STRING) *rr_to, int rr_allorfirst, |
@@ -1442,7 +1441,6 @@ cms_main(int argc, char **argv) | |||
1442 | if ((store = setup_verify(bio_err, cfg.CAfile, | 1441 | if ((store = setup_verify(bio_err, cfg.CAfile, |
1443 | cfg.CApath)) == NULL) | 1442 | cfg.CApath)) == NULL) |
1444 | goto end; | 1443 | goto end; |
1445 | X509_STORE_set_verify_cb(store, cms_cb); | ||
1446 | if (cfg.vpm != NULL) { | 1444 | if (cfg.vpm != NULL) { |
1447 | if (!X509_STORE_set1_param(store, cfg.vpm)) | 1445 | if (!X509_STORE_set1_param(store, cfg.vpm)) |
1448 | goto end; | 1446 | goto end; |
@@ -1804,26 +1802,6 @@ save_certs(char *signerfile, STACK_OF(X509) *signers) | |||
1804 | return 1; | 1802 | return 1; |
1805 | } | 1803 | } |
1806 | 1804 | ||
1807 | /* Minimal callback just to output policy info (if any) */ | ||
1808 | |||
1809 | static int | ||
1810 | cms_cb(int ok, X509_STORE_CTX *ctx) | ||
1811 | { | ||
1812 | int error; | ||
1813 | |||
1814 | error = X509_STORE_CTX_get_error(ctx); | ||
1815 | |||
1816 | verify_err = error; | ||
1817 | |||
1818 | if ((error != X509_V_ERR_NO_EXPLICIT_POLICY) && | ||
1819 | ((error != X509_V_OK) || (ok != 2))) | ||
1820 | return ok; | ||
1821 | |||
1822 | policies_print(NULL, ctx); | ||
1823 | |||
1824 | return ok; | ||
1825 | } | ||
1826 | |||
1827 | static void | 1805 | static void |
1828 | gnames_stack_print(BIO *out, STACK_OF(GENERAL_NAMES) *gns) | 1806 | gnames_stack_print(BIO *out, STACK_OF(GENERAL_NAMES) *gns) |
1829 | { | 1807 | { |
diff --git a/src/usr.bin/openssl/s_cb.c b/src/usr.bin/openssl/s_cb.c index 73f45c25c5..d503b8cf27 100644 --- a/src/usr.bin/openssl/s_cb.c +++ b/src/usr.bin/openssl/s_cb.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s_cb.c,v 1.20 2022/08/31 07:12:30 tb Exp $ */ | 1 | /* $OpenBSD: s_cb.c,v 1.21 2023/04/14 15:27:13 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 | * |
@@ -189,11 +189,8 @@ verify_callback(int ok, X509_STORE_CTX * ctx) | |||
189 | BIO_printf(bio_err, "\n"); | 189 | BIO_printf(bio_err, "\n"); |
190 | break; | 190 | break; |
191 | case X509_V_ERR_NO_EXPLICIT_POLICY: | 191 | case X509_V_ERR_NO_EXPLICIT_POLICY: |
192 | policies_print(bio_err, ctx); | ||
193 | break; | 192 | break; |
194 | } | 193 | } |
195 | if (err == X509_V_OK && ok == 2) | ||
196 | policies_print(bio_err, ctx); | ||
197 | 194 | ||
198 | BIO_printf(bio_err, "verify return:%d\n", ok); | 195 | BIO_printf(bio_err, "verify return:%d\n", ok); |
199 | return (ok); | 196 | return (ok); |
diff --git a/src/usr.bin/openssl/smime.c b/src/usr.bin/openssl/smime.c index e54c8d0b84..46bfa08679 100644 --- a/src/usr.bin/openssl/smime.c +++ b/src/usr.bin/openssl/smime.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: smime.c,v 1.19 2023/03/06 14:32:06 tb Exp $ */ | 1 | /* $OpenBSD: smime.c,v 1.20 2023/04/14 15:27:13 tb Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project. | 3 | * project. |
4 | */ | 4 | */ |
@@ -70,7 +70,6 @@ | |||
70 | #include <openssl/x509v3.h> | 70 | #include <openssl/x509v3.h> |
71 | 71 | ||
72 | static int save_certs(char *signerfile, STACK_OF(X509) *signers); | 72 | static int save_certs(char *signerfile, STACK_OF(X509) *signers); |
73 | static int smime_cb(int ok, X509_STORE_CTX *ctx); | ||
74 | 73 | ||
75 | #define SMIME_OP 0x10 | 74 | #define SMIME_OP 0x10 |
76 | #define SMIME_IP 0x20 | 75 | #define SMIME_IP 0x20 |
@@ -933,7 +932,6 @@ smime_main(int argc, char **argv) | |||
933 | if ((store = setup_verify(bio_err, cfg.CAfile, | 932 | if ((store = setup_verify(bio_err, cfg.CAfile, |
934 | cfg.CApath)) == NULL) | 933 | cfg.CApath)) == NULL) |
935 | goto end; | 934 | goto end; |
936 | X509_STORE_set_verify_cb(store, smime_cb); | ||
937 | if (cfg.vpm != NULL) { | 935 | if (cfg.vpm != NULL) { |
938 | if (!X509_STORE_set1_param(store, cfg.vpm)) | 936 | if (!X509_STORE_set1_param(store, cfg.vpm)) |
939 | goto end; | 937 | goto end; |
@@ -1103,20 +1101,3 @@ save_certs(char *signerfile, STACK_OF(X509) *signers) | |||
1103 | 1101 | ||
1104 | return 1; | 1102 | return 1; |
1105 | } | 1103 | } |
1106 | |||
1107 | /* Minimal callback just to output policy info (if any) */ | ||
1108 | static int | ||
1109 | smime_cb(int ok, X509_STORE_CTX *ctx) | ||
1110 | { | ||
1111 | int error; | ||
1112 | |||
1113 | error = X509_STORE_CTX_get_error(ctx); | ||
1114 | |||
1115 | if ((error != X509_V_ERR_NO_EXPLICIT_POLICY) && | ||
1116 | ((error != X509_V_OK) || (ok != 2))) | ||
1117 | return ok; | ||
1118 | |||
1119 | policies_print(NULL, ctx); | ||
1120 | |||
1121 | return ok; | ||
1122 | } | ||
diff --git a/src/usr.bin/openssl/verify.c b/src/usr.bin/openssl/verify.c index b412623991..b4e0f33f6a 100644 --- a/src/usr.bin/openssl/verify.c +++ b/src/usr.bin/openssl/verify.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: verify.c,v 1.16 2023/03/06 14:32:06 tb Exp $ */ | 1 | /* $OpenBSD: verify.c,v 1.17 2023/04/14 15:27:13 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 | * |
@@ -427,7 +427,6 @@ cb(int ok, X509_STORE_CTX *ctx) | |||
427 | X509_verify_cert_error_string(cert_error)); | 427 | X509_verify_cert_error_string(cert_error)); |
428 | switch (cert_error) { | 428 | switch (cert_error) { |
429 | case X509_V_ERR_NO_EXPLICIT_POLICY: | 429 | case X509_V_ERR_NO_EXPLICIT_POLICY: |
430 | policies_print(NULL, ctx); | ||
431 | case X509_V_ERR_CERT_HAS_EXPIRED: | 430 | case X509_V_ERR_CERT_HAS_EXPIRED: |
432 | 431 | ||
433 | /* | 432 | /* |
@@ -452,8 +451,6 @@ cb(int ok, X509_STORE_CTX *ctx) | |||
452 | return ok; | 451 | return ok; |
453 | 452 | ||
454 | } | 453 | } |
455 | if (cert_error == X509_V_OK && ok == 2) | ||
456 | policies_print(NULL, ctx); | ||
457 | if (!cfg.verbose) | 454 | if (!cfg.verbose) |
458 | ERR_clear_error(); | 455 | ERR_clear_error(); |
459 | return (ok); | 456 | return (ok); |