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