/src/openssl32/crypto/x509/x509_txt.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
2  |  |  * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.  | 
3  |  |  *  | 
4  |  |  * Licensed under the Apache License 2.0 (the "License").  You may not use  | 
5  |  |  * this file except in compliance with the License.  You can obtain a copy  | 
6  |  |  * in the file LICENSE in the source distribution or at  | 
7  |  |  * https://www.openssl.org/source/license.html  | 
8  |  |  */  | 
9  |  |  | 
10  |  | #include <stdio.h>  | 
11  |  | #include <time.h>  | 
12  |  | #include <errno.h>  | 
13  |  |  | 
14  |  | #include "internal/cryptlib.h"  | 
15  |  | #include <openssl/buffer.h>  | 
16  |  | #include <openssl/evp.h>  | 
17  |  | #include <openssl/asn1.h>  | 
18  |  | #include <openssl/x509.h>  | 
19  |  | #include <openssl/objects.h>  | 
20  |  |  | 
21  |  | const char *X509_verify_cert_error_string(long n)  | 
22  | 778  | { | 
23  | 778  |     switch ((int)n) { | 
24  | 612  |     case X509_V_OK:  | 
25  | 612  |         return "ok";  | 
26  | 0  |     case X509_V_ERR_UNSPECIFIED:  | 
27  | 0  |         return "unspecified certificate verification error";  | 
28  | 1  |     case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:  | 
29  | 1  |         return "unable to get issuer certificate";  | 
30  | 0  |     case X509_V_ERR_UNABLE_TO_GET_CRL:  | 
31  | 0  |         return "unable to get certificate CRL";  | 
32  | 2  |     case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE:  | 
33  | 2  |         return "unable to decrypt certificate's signature";  | 
34  | 1  |     case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE:  | 
35  | 1  |         return "unable to decrypt CRL's signature";  | 
36  | 1  |     case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY:  | 
37  | 1  |         return "unable to decode issuer public key";  | 
38  | 2  |     case X509_V_ERR_CERT_SIGNATURE_FAILURE:  | 
39  | 2  |         return "certificate signature failure";  | 
40  | 1  |     case X509_V_ERR_CRL_SIGNATURE_FAILURE:  | 
41  | 1  |         return "CRL signature failure";  | 
42  | 1  |     case X509_V_ERR_CERT_NOT_YET_VALID:  | 
43  | 1  |         return "certificate is not yet valid";  | 
44  | 2  |     case X509_V_ERR_CERT_HAS_EXPIRED:  | 
45  | 2  |         return "certificate has expired";  | 
46  | 2  |     case X509_V_ERR_CRL_NOT_YET_VALID:  | 
47  | 2  |         return "CRL is not yet valid";  | 
48  | 2  |     case X509_V_ERR_CRL_HAS_EXPIRED:  | 
49  | 2  |         return "CRL has expired";  | 
50  | 1  |     case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:  | 
51  | 1  |         return "format error in certificate's notBefore field";  | 
52  | 1  |     case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:  | 
53  | 1  |         return "format error in certificate's notAfter field";  | 
54  | 0  |     case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD:  | 
55  | 0  |         return "format error in CRL's lastUpdate field";  | 
56  | 1  |     case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD:  | 
57  | 1  |         return "format error in CRL's nextUpdate field";  | 
58  | 1  |     case X509_V_ERR_OUT_OF_MEM:  | 
59  | 1  |         return "out of memory";  | 
60  | 1  |     case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:  | 
61  | 1  |         return "self-signed certificate";  | 
62  | 2  |     case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:  | 
63  | 2  |         return "self-signed certificate in certificate chain";  | 
64  | 1  |     case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:  | 
65  | 1  |         return "unable to get local issuer certificate";  | 
66  | 1  |     case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:  | 
67  | 1  |         return "unable to verify the first certificate";  | 
68  | 1  |     case X509_V_ERR_CERT_CHAIN_TOO_LONG:  | 
69  | 1  |         return "certificate chain too long";  | 
70  | 1  |     case X509_V_ERR_CERT_REVOKED:  | 
71  | 1  |         return "certificate revoked";  | 
72  | 2  |     case X509_V_ERR_NO_ISSUER_PUBLIC_KEY:  | 
73  | 2  |         return "issuer certificate doesn't have a public key";  | 
74  | 2  |     case X509_V_ERR_PATH_LENGTH_EXCEEDED:  | 
75  | 2  |         return "path length constraint exceeded";  | 
76  | 3  |     case X509_V_ERR_INVALID_PURPOSE:  | 
77  | 3  |         return "unsuitable certificate purpose";  | 
78  | 1  |     case X509_V_ERR_CERT_UNTRUSTED:  | 
79  | 1  |         return "certificate not trusted";  | 
80  | 2  |     case X509_V_ERR_CERT_REJECTED:  | 
81  | 2  |         return "certificate rejected";  | 
82  | 1  |     case X509_V_ERR_SUBJECT_ISSUER_MISMATCH:  | 
83  | 1  |         return "subject issuer mismatch";  | 
84  | 1  |     case X509_V_ERR_AKID_SKID_MISMATCH:  | 
85  | 1  |         return "authority and subject key identifier mismatch";  | 
86  | 1  |     case X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH:  | 
87  | 1  |         return "authority and issuer serial number mismatch";  | 
88  | 2  |     case X509_V_ERR_KEYUSAGE_NO_CERTSIGN:  | 
89  | 2  |         return "key usage does not include certificate signing";  | 
90  | 1  |     case X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER:  | 
91  | 1  |         return "unable to get CRL issuer certificate";  | 
92  | 0  |     case X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION:  | 
93  | 0  |         return "unhandled critical extension";  | 
94  | 0  |     case X509_V_ERR_KEYUSAGE_NO_CRL_SIGN:  | 
95  | 0  |         return "key usage does not include CRL signing";  | 
96  | 1  |     case X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION:  | 
97  | 1  |         return "unhandled critical CRL extension";  | 
98  | 2  |     case X509_V_ERR_INVALID_NON_CA:  | 
99  | 2  |         return "invalid non-CA certificate (has CA markings)";  | 
100  | 1  |     case X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED:  | 
101  | 1  |         return "proxy path length constraint exceeded";  | 
102  | 1  |     case X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE:  | 
103  | 1  |         return "key usage does not include digital signature";  | 
104  | 1  |     case X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED:  | 
105  | 1  |         return  | 
106  | 1  |             "proxy certificates not allowed, please set the appropriate flag";  | 
107  | 2  |     case X509_V_ERR_INVALID_EXTENSION:  | 
108  | 2  |         return "invalid or inconsistent certificate extension";  | 
109  | 1  |     case X509_V_ERR_INVALID_POLICY_EXTENSION:  | 
110  | 1  |         return "invalid or inconsistent certificate policy extension";  | 
111  | 1  |     case X509_V_ERR_NO_EXPLICIT_POLICY:  | 
112  | 1  |         return "no explicit policy";  | 
113  | 1  |     case X509_V_ERR_DIFFERENT_CRL_SCOPE:  | 
114  | 1  |         return "different CRL scope";  | 
115  | 1  |     case X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE:  | 
116  | 1  |         return "unsupported extension feature";  | 
117  | 1  |     case X509_V_ERR_UNNESTED_RESOURCE:  | 
118  | 1  |         return "RFC 3779 resource not subset of parent's resources";  | 
119  | 0  |     case X509_V_ERR_PERMITTED_VIOLATION:  | 
120  | 0  |         return "permitted subtree violation";  | 
121  | 0  |     case X509_V_ERR_EXCLUDED_VIOLATION:  | 
122  | 0  |         return "excluded subtree violation";  | 
123  | 3  |     case X509_V_ERR_SUBTREE_MINMAX:  | 
124  | 3  |         return "name constraints minimum and maximum not supported";  | 
125  | 2  |     case X509_V_ERR_APPLICATION_VERIFICATION:  | 
126  | 2  |         return "application verification failure";  | 
127  | 2  |     case X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE:  | 
128  | 2  |         return "unsupported name constraint type";  | 
129  | 0  |     case X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX:  | 
130  | 0  |         return "unsupported or invalid name constraint syntax";  | 
131  | 3  |     case X509_V_ERR_UNSUPPORTED_NAME_SYNTAX:  | 
132  | 3  |         return "unsupported or invalid name syntax";  | 
133  | 1  |     case X509_V_ERR_CRL_PATH_VALIDATION_ERROR:  | 
134  | 1  |         return "CRL path validation error";  | 
135  | 1  |     case X509_V_ERR_PATH_LOOP:  | 
136  | 1  |         return "path loop";  | 
137  | 0  |     case X509_V_ERR_SUITE_B_INVALID_VERSION:  | 
138  | 0  |         return "Suite B: certificate version invalid";  | 
139  | 1  |     case X509_V_ERR_SUITE_B_INVALID_ALGORITHM:  | 
140  | 1  |         return "Suite B: invalid public key algorithm";  | 
141  | 2  |     case X509_V_ERR_SUITE_B_INVALID_CURVE:  | 
142  | 2  |         return "Suite B: invalid ECC curve";  | 
143  | 1  |     case X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM:  | 
144  | 1  |         return "Suite B: invalid signature algorithm";  | 
145  | 0  |     case X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED:  | 
146  | 0  |         return "Suite B: curve not allowed for this LOS";  | 
147  | 1  |     case X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256:  | 
148  | 1  |         return "Suite B: cannot sign P-384 with P-256";  | 
149  | 1  |     case X509_V_ERR_HOSTNAME_MISMATCH:  | 
150  | 1  |         return "hostname mismatch";  | 
151  | 1  |     case X509_V_ERR_EMAIL_MISMATCH:  | 
152  | 1  |         return "email address mismatch";  | 
153  | 2  |     case X509_V_ERR_IP_ADDRESS_MISMATCH:  | 
154  | 2  |         return "IP address mismatch";  | 
155  | 1  |     case X509_V_ERR_DANE_NO_MATCH:  | 
156  | 1  |         return "no matching DANE TLSA records";  | 
157  | 1  |     case X509_V_ERR_EE_KEY_TOO_SMALL:  | 
158  | 1  |         return "EE certificate key too weak";  | 
159  | 2  |     case X509_V_ERR_CA_KEY_TOO_SMALL:  | 
160  | 2  |         return "CA certificate key too weak";  | 
161  | 0  |     case X509_V_ERR_CA_MD_TOO_WEAK:  | 
162  | 0  |         return "CA signature digest algorithm too weak";  | 
163  | 2  |     case X509_V_ERR_INVALID_CALL:  | 
164  | 2  |         return "invalid certificate verification context";  | 
165  | 1  |     case X509_V_ERR_STORE_LOOKUP:  | 
166  | 1  |         return "issuer certificate lookup error";  | 
167  | 2  |     case X509_V_ERR_NO_VALID_SCTS:  | 
168  | 2  |         return "Certificate Transparency required, but no valid SCTs found";  | 
169  | 1  |     case X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION:  | 
170  | 1  |         return "proxy subject name violation";  | 
171  | 2  |     case X509_V_ERR_OCSP_VERIFY_NEEDED:  | 
172  | 2  |         return "OCSP verification needed";  | 
173  | 2  |     case X509_V_ERR_OCSP_VERIFY_FAILED:  | 
174  | 2  |         return "OCSP verification failed";  | 
175  | 0  |     case X509_V_ERR_OCSP_CERT_UNKNOWN:  | 
176  | 0  |         return "OCSP unknown cert";  | 
177  | 2  |     case X509_V_ERR_UNSUPPORTED_SIGNATURE_ALGORITHM:  | 
178  | 2  |         return "Cannot find certificate signature algorithm";  | 
179  | 0  |     case X509_V_ERR_SIGNATURE_ALGORITHM_MISMATCH:  | 
180  | 0  |         return "subject signature algorithm and issuer public key algorithm mismatch";  | 
181  | 1  |     case X509_V_ERR_SIGNATURE_ALGORITHM_INCONSISTENCY:  | 
182  | 1  |         return "cert info signature and signature algorithm mismatch";  | 
183  | 1  |     case X509_V_ERR_INVALID_CA:  | 
184  | 1  |         return "invalid CA certificate";  | 
185  | 1  |     case X509_V_ERR_PATHLEN_INVALID_FOR_NON_CA:  | 
186  | 1  |         return "Path length invalid for non-CA cert";  | 
187  | 0  |     case X509_V_ERR_PATHLEN_WITHOUT_KU_KEY_CERT_SIGN:  | 
188  | 0  |         return "Path length given without key usage keyCertSign";  | 
189  | 1  |     case X509_V_ERR_KU_KEY_CERT_SIGN_INVALID_FOR_NON_CA:  | 
190  | 1  |         return "Key usage keyCertSign invalid for non-CA cert";  | 
191  | 2  |     case X509_V_ERR_ISSUER_NAME_EMPTY:  | 
192  | 2  |         return "Issuer name empty";  | 
193  | 1  |     case X509_V_ERR_SUBJECT_NAME_EMPTY:  | 
194  | 1  |         return "Subject name empty";  | 
195  | 1  |     case X509_V_ERR_MISSING_AUTHORITY_KEY_IDENTIFIER:  | 
196  | 1  |         return "Missing Authority Key Identifier";  | 
197  | 0  |     case X509_V_ERR_MISSING_SUBJECT_KEY_IDENTIFIER:  | 
198  | 0  |         return "Missing Subject Key Identifier";  | 
199  | 1  |     case X509_V_ERR_EMPTY_SUBJECT_ALT_NAME:  | 
200  | 1  |         return "Empty Subject Alternative Name extension";  | 
201  | 2  |     case X509_V_ERR_CA_BCONS_NOT_CRITICAL:  | 
202  | 2  |         return "Basic Constraints of CA cert not marked critical";  | 
203  | 0  |     case X509_V_ERR_EMPTY_SUBJECT_SAN_NOT_CRITICAL:  | 
204  | 0  |         return "Subject empty and Subject Alt Name extension not critical";  | 
205  | 1  |     case X509_V_ERR_AUTHORITY_KEY_IDENTIFIER_CRITICAL:  | 
206  | 1  |         return "Authority Key Identifier marked critical";  | 
207  | 1  |     case X509_V_ERR_SUBJECT_KEY_IDENTIFIER_CRITICAL:  | 
208  | 1  |         return "Subject Key Identifier marked critical";  | 
209  | 2  |     case X509_V_ERR_CA_CERT_MISSING_KEY_USAGE:  | 
210  | 2  |         return "CA cert does not include key usage extension";  | 
211  | 2  |     case X509_V_ERR_EXTENSIONS_REQUIRE_VERSION_3:  | 
212  | 2  |         return "Using cert extension requires at least X509v3";  | 
213  | 1  |     case X509_V_ERR_EC_KEY_EXPLICIT_PARAMS:  | 
214  | 1  |         return "Certificate public key has explicit ECC parameters";  | 
215  | 2  |     case X509_V_ERR_RPK_UNTRUSTED:  | 
216  | 2  |         return "Raw public key untrusted, no trusted keys configured";  | 
217  |  |  | 
218  |  |         /*  | 
219  |  |          * Entries must be kept consistent with include/openssl/x509_vfy.h.in  | 
220  |  |          * and with doc/man3/X509_STORE_CTX_get_error.pod  | 
221  |  |          */  | 
222  |  |  | 
223  | 54  |     default:  | 
224  |  |         /* Printing an error number into a static buffer is not thread-safe */  | 
225  | 54  |         return "unknown certificate verification error";  | 
226  | 778  |     }  | 
227  | 778  | }  |