1238438Sdteske/* crypto/x509/x509_txt.c */ 2238438Sdteske/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3238438Sdteske * All rights reserved. 4238438Sdteske * 5238438Sdteske * This package is an SSL implementation written 6238438Sdteske * by Eric Young (eay@cryptsoft.com). 7238438Sdteske * The implementation was written so as to conform with Netscapes SSL. 8238438Sdteske * 9238438Sdteske * This library is free for commercial and non-commercial use as long as 10238438Sdteske * the following conditions are aheared to. The following conditions 11238438Sdteske * apply to all code found in this distribution, be it the RC4, RSA, 12238438Sdteske * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13238438Sdteske * included with this distribution is covered by the same copyright terms 14238438Sdteske * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15238438Sdteske * 16238438Sdteske * Copyright remains Eric Young's, and as such any Copyright notices in 17238438Sdteske * the code are not to be removed. 18238438Sdteske * If this package is used in a product, Eric Young should be given attribution 19238438Sdteske * as the author of the parts of the library used. 20238438Sdteske * This can be in the form of a textual message at program startup or 21238438Sdteske * in documentation (online or textual) provided with the package. 22238438Sdteske * 23238438Sdteske * Redistribution and use in source and binary forms, with or without 24238438Sdteske * modification, are permitted provided that the following conditions 25238438Sdteske * are met: 26238438Sdteske * 1. Redistributions of source code must retain the copyright 27238438Sdteske * notice, this list of conditions and the following disclaimer. 28238438Sdteske * 2. Redistributions in binary form must reproduce the above copyright 29238438Sdteske * notice, this list of conditions and the following disclaimer in the 30238438Sdteske * documentation and/or other materials provided with the distribution. 31240684Sdteske * 3. All advertising materials mentioning features or use of this software 32240684Sdteske * must display the following acknowledgement: 33240684Sdteske * "This product includes cryptographic software written by 34240684Sdteske * Eric Young (eay@cryptsoft.com)" 35240684Sdteske * The word 'cryptographic' can be left out if the rouines from the library 36238438Sdteske * being used are not cryptographic related :-). 37240684Sdteske * 4. If you include any Windows specific code (or a derivative thereof) from 38238438Sdteske * the apps directory (application code) you must include an acknowledgement: 39238438Sdteske * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40238438Sdteske * 41238438Sdteske * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42238438Sdteske * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43238438Sdteske * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44238438Sdteske * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45238438Sdteske * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46238438Sdteske * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47238438Sdteske * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48238438Sdteske * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49238438Sdteske * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50238438Sdteske * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51238438Sdteske * SUCH DAMAGE. 52238438Sdteske * 53238438Sdteske * The licence and distribution terms for any publically available version or 54238438Sdteske * derivative of this code cannot be changed. i.e. this code cannot simply be 55238438Sdteske * copied and put under another distribution licence 56238438Sdteske * [including the GNU Public Licence.] 57238438Sdteske */ 58238438Sdteske 59238438Sdteske#include <stdio.h> 60238438Sdteske#include <time.h> 61238438Sdteske#include <errno.h> 62238438Sdteske 63238438Sdteske#include "cryptlib.h" 64238438Sdteske#include <openssl/lhash.h> 65238438Sdteske#include <openssl/buffer.h> 66238438Sdteske#include <openssl/evp.h> 67238438Sdteske#include <openssl/asn1.h> 68238438Sdteske#include <openssl/x509.h> 69238438Sdteske#include <openssl/objects.h> 70238438Sdteske 71240768Sdteskeconst char *X509_verify_cert_error_string(long n) 72240768Sdteske{ 73238438Sdteske static char buf[100]; 74238438Sdteske 75238438Sdteske switch ((int)n) { 76238438Sdteske case X509_V_OK: 77238438Sdteske return ("ok"); 78238438Sdteske case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: 79238438Sdteske return ("unable to get issuer certificate"); 80240768Sdteske case X509_V_ERR_UNABLE_TO_GET_CRL: 81240768Sdteske return ("unable to get certificate CRL"); 82240768Sdteske case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: 83240768Sdteske return ("unable to decrypt certificate's signature"); 84240768Sdteske case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: 85238438Sdteske return ("unable to decrypt CRL's signature"); 86238438Sdteske case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: 87238438Sdteske return ("unable to decode issuer public key"); 88238438Sdteske case X509_V_ERR_CERT_SIGNATURE_FAILURE: 89238438Sdteske return ("certificate signature failure"); 90238438Sdteske case X509_V_ERR_CRL_SIGNATURE_FAILURE: 91238438Sdteske return ("CRL signature failure"); 92238438Sdteske case X509_V_ERR_CERT_NOT_YET_VALID: 93238438Sdteske return ("certificate is not yet valid"); 94238438Sdteske case X509_V_ERR_CRL_NOT_YET_VALID: 95238438Sdteske return ("CRL is not yet valid"); 96238438Sdteske case X509_V_ERR_CERT_HAS_EXPIRED: 97238438Sdteske return ("certificate has expired"); 98238438Sdteske case X509_V_ERR_CRL_HAS_EXPIRED: 99238438Sdteske return ("CRL has expired"); 100238438Sdteske case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: 101238438Sdteske return ("format error in certificate's notBefore field"); 102238438Sdteske case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: 103238438Sdteske return ("format error in certificate's notAfter field"); 104238438Sdteske case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: 105238438Sdteske return ("format error in CRL's lastUpdate field"); 106238438Sdteske case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: 107238438Sdteske return ("format error in CRL's nextUpdate field"); 108238438Sdteske case X509_V_ERR_OUT_OF_MEM: 109238438Sdteske return ("out of memory"); 110238438Sdteske case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: 111238438Sdteske return ("self signed certificate"); 112238438Sdteske case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: 113238438Sdteske return ("self signed certificate in certificate chain"); 114238438Sdteske case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: 115238438Sdteske return ("unable to get local issuer certificate"); 116238438Sdteske case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: 117238438Sdteske return ("unable to verify the first certificate"); 118238438Sdteske case X509_V_ERR_CERT_CHAIN_TOO_LONG: 119238438Sdteske return ("certificate chain too long"); 120238438Sdteske case X509_V_ERR_CERT_REVOKED: 121238438Sdteske return ("certificate revoked"); 122238438Sdteske case X509_V_ERR_INVALID_CA: 123238438Sdteske return ("invalid CA certificate"); 124238438Sdteske case X509_V_ERR_INVALID_NON_CA: 125238438Sdteske return ("invalid non-CA certificate (has CA markings)"); 126238438Sdteske case X509_V_ERR_PATH_LENGTH_EXCEEDED: 127238438Sdteske return ("path length constraint exceeded"); 128238438Sdteske case X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED: 129238438Sdteske return ("proxy path length constraint exceeded"); 130238438Sdteske case X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED: 131238438Sdteske return 132238438Sdteske ("proxy certificates not allowed, please set the appropriate flag"); 133238438Sdteske case X509_V_ERR_INVALID_PURPOSE: 134238438Sdteske return ("unsupported certificate purpose"); 135238438Sdteske case X509_V_ERR_CERT_UNTRUSTED: 136238438Sdteske return ("certificate not trusted"); 137238438Sdteske case X509_V_ERR_CERT_REJECTED: 138238438Sdteske return ("certificate rejected"); 139238438Sdteske case X509_V_ERR_APPLICATION_VERIFICATION: 140238438Sdteske return ("application verification failure"); 141238438Sdteske case X509_V_ERR_SUBJECT_ISSUER_MISMATCH: 142238438Sdteske return ("subject issuer mismatch"); 143238438Sdteske case X509_V_ERR_AKID_SKID_MISMATCH: 144238438Sdteske return ("authority and subject key identifier mismatch"); 145238438Sdteske case X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: 146238438Sdteske return ("authority and issuer serial number mismatch"); 147238438Sdteske case X509_V_ERR_KEYUSAGE_NO_CERTSIGN: 148 return ("key usage does not include certificate signing"); 149 case X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER: 150 return ("unable to get CRL issuer certificate"); 151 case X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION: 152 return ("unhandled critical extension"); 153 case X509_V_ERR_KEYUSAGE_NO_CRL_SIGN: 154 return ("key usage does not include CRL signing"); 155 case X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE: 156 return ("key usage does not include digital signature"); 157 case X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION: 158 return ("unhandled critical CRL extension"); 159 case X509_V_ERR_INVALID_EXTENSION: 160 return ("invalid or inconsistent certificate extension"); 161 case X509_V_ERR_INVALID_POLICY_EXTENSION: 162 return ("invalid or inconsistent certificate policy extension"); 163 case X509_V_ERR_NO_EXPLICIT_POLICY: 164 return ("no explicit policy"); 165 case X509_V_ERR_DIFFERENT_CRL_SCOPE: 166 return ("Different CRL scope"); 167 case X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE: 168 return ("Unsupported extension feature"); 169 case X509_V_ERR_UNNESTED_RESOURCE: 170 return ("RFC 3779 resource not subset of parent's resources"); 171 172 case X509_V_ERR_PERMITTED_VIOLATION: 173 return ("permitted subtree violation"); 174 case X509_V_ERR_EXCLUDED_VIOLATION: 175 return ("excluded subtree violation"); 176 case X509_V_ERR_SUBTREE_MINMAX: 177 return ("name constraints minimum and maximum not supported"); 178 case X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE: 179 return ("unsupported name constraint type"); 180 case X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX: 181 return ("unsupported or invalid name constraint syntax"); 182 case X509_V_ERR_UNSUPPORTED_NAME_SYNTAX: 183 return ("unsupported or invalid name syntax"); 184 case X509_V_ERR_CRL_PATH_VALIDATION_ERROR: 185 return ("CRL path validation error"); 186 case X509_V_ERR_INVALID_CALL: 187 return ("Invalid certificate verification context"); 188 case X509_V_ERR_STORE_LOOKUP: 189 return ("Issuer certificate lookup error"); 190 case X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION: 191 return ("proxy subject name violation"); 192 193 default: 194 BIO_snprintf(buf, sizeof buf, "error number %ld", n); 195 return (buf); 196 } 197} 198