diff options
Diffstat (limited to 'src/lib/libcrypto/x509v3/v3conf.c')
-rw-r--r-- | src/lib/libcrypto/x509v3/v3conf.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/lib/libcrypto/x509v3/v3conf.c b/src/lib/libcrypto/x509v3/v3conf.c index a9e6ca3542..cfa5fce75c 100644 --- a/src/lib/libcrypto/x509v3/v3conf.c +++ b/src/lib/libcrypto/x509v3/v3conf.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -66,7 +66,8 @@ | |||
66 | 66 | ||
67 | /* Test application to add extensions from a config file */ | 67 | /* Test application to add extensions from a config file */ |
68 | 68 | ||
69 | int main(int argc, char **argv) | 69 | int |
70 | main(int argc, char **argv) | ||
70 | { | 71 | { |
71 | LHASH *conf; | 72 | LHASH *conf; |
72 | X509 *cert; | 73 | X509 *cert; |
@@ -75,28 +76,30 @@ int main(int argc, char **argv) | |||
75 | int i; | 76 | int i; |
76 | int count; | 77 | int count; |
77 | X509_EXTENSION *ext; | 78 | X509_EXTENSION *ext; |
79 | |||
78 | X509V3_add_standard_extensions(); | 80 | X509V3_add_standard_extensions(); |
79 | ERR_load_crypto_strings(); | 81 | ERR_load_crypto_strings(); |
80 | if(!argv[1]) { | 82 | if (!argv[1]) { |
81 | fprintf(stderr, "Usage: v3conf cert.pem [file.cnf]\n"); | 83 | fprintf(stderr, "Usage: v3conf cert.pem [file.cnf]\n"); |
82 | exit(1); | 84 | exit(1); |
83 | } | 85 | } |
84 | conf_file = argv[2]; | 86 | conf_file = argv[2]; |
85 | if(!conf_file) conf_file = "test.cnf"; | 87 | if (!conf_file) |
88 | conf_file = "test.cnf"; | ||
86 | conf = CONF_load(NULL, "test.cnf", NULL); | 89 | conf = CONF_load(NULL, "test.cnf", NULL); |
87 | if(!conf) { | 90 | if (!conf) { |
88 | fprintf(stderr, "Error opening Config file %s\n", conf_file); | 91 | fprintf(stderr, "Error opening Config file %s\n", conf_file); |
89 | ERR_print_errors_fp(stderr); | 92 | ERR_print_errors_fp(stderr); |
90 | exit(1); | 93 | exit(1); |
91 | } | 94 | } |
92 | 95 | ||
93 | inf = fopen(argv[1], "r"); | 96 | inf = fopen(argv[1], "r"); |
94 | if(!inf) { | 97 | if (!inf) { |
95 | fprintf(stderr, "Can't open certificate file %s\n", argv[1]); | 98 | fprintf(stderr, "Can't open certificate file %s\n", argv[1]); |
96 | exit(1); | 99 | exit(1); |
97 | } | 100 | } |
98 | cert = PEM_read_X509(inf, NULL, NULL); | 101 | cert = PEM_read_X509(inf, NULL, NULL); |
99 | if(!cert) { | 102 | if (!cert) { |
100 | fprintf(stderr, "Error reading certificate file %s\n", argv[1]); | 103 | fprintf(stderr, "Error reading certificate file %s\n", argv[1]); |
101 | exit(1); | 104 | exit(1); |
102 | } | 105 | } |
@@ -105,7 +108,7 @@ int main(int argc, char **argv) | |||
105 | sk_pop_free(cert->cert_info->extensions, X509_EXTENSION_free); | 108 | sk_pop_free(cert->cert_info->extensions, X509_EXTENSION_free); |
106 | cert->cert_info->extensions = NULL; | 109 | cert->cert_info->extensions = NULL; |
107 | 110 | ||
108 | if(!X509V3_EXT_add_conf(conf, NULL, "test_section", cert)) { | 111 | if (!X509V3_EXT_add_conf(conf, NULL, "test_section", cert)) { |
109 | fprintf(stderr, "Error adding extensions\n"); | 112 | fprintf(stderr, "Error adding extensions\n"); |
110 | ERR_print_errors_fp(stderr); | 113 | ERR_print_errors_fp(stderr); |
111 | exit(1); | 114 | exit(1); |
@@ -113,15 +116,16 @@ int main(int argc, char **argv) | |||
113 | 116 | ||
114 | count = X509_get_ext_count(cert); | 117 | count = X509_get_ext_count(cert); |
115 | printf("%d extensions\n", count); | 118 | printf("%d extensions\n", count); |
116 | for(i = 0; i < count; i++) { | 119 | for (i = 0; i < count; i++) { |
117 | ext = X509_get_ext(cert, i); | 120 | ext = X509_get_ext(cert, i); |
118 | printf("%s", OBJ_nid2ln(OBJ_obj2nid(ext->object))); | 121 | printf("%s", OBJ_nid2ln(OBJ_obj2nid(ext->object))); |
119 | if(ext->critical) printf(",critical:\n"); | 122 | if (ext->critical) |
120 | else printf(":\n"); | 123 | printf(",critical:\n"); |
124 | else | ||
125 | printf(":\n"); | ||
121 | X509V3_EXT_print_fp(stdout, ext, 0, 0); | 126 | X509V3_EXT_print_fp(stdout, ext, 0, 0); |
122 | printf("\n"); | 127 | printf("\n"); |
123 | 128 | ||
124 | } | 129 | } |
125 | return 0; | 130 | return 0; |
126 | } | 131 | } |
127 | |||