Skip to content

Commit 3557fae

Browse files
committed
Document the x509 error codes
Signed-off-by: Dan Čermák <dcermak@suse.com>
1 parent 2e1e02a commit 3557fae

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

doc/api/tls.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,47 @@ The first 3 are enabled by default. The last 2 `CCM`-based suites are supported
370370
by TLSv1.3 because they may be more performant on constrained systems, but they
371371
are not enabled by default since they offer less security.
372372

373+
374+
## X509 Certificate Error codes
375+
376+
Multiple functions can fail due to certificate errors that are reported by
377+
openssl. In such a case, the function provides a `Error` via its callback that
378+
has the property `code` which can take one of the following values:
379+
380+
<!--
381+
values are taken from src/crypto/crypto_common.cc
382+
description are taken from deps/openssl/openssl/crypto/x509/x509_txt.c
383+
-->
384+
* `'UNABLE_TO_GET_ISSUER_CERT'`: unable to get issuer certificate
385+
* `'UNABLE_TO_GET_CRL'`: unable to get certificate CRL
386+
* `'UNABLE_TO_DECRYPT_CERT_SIGNATURE'`: unable to decrypt certificate's signature
387+
* `'UNABLE_TO_DECRYPT_CRL_SIGNATURE'`: unable to decrypt CRL's signature
388+
* `'UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY'`: unable to decode issuer public key
389+
* `'CERT_SIGNATURE_FAILURE'`: certificate signature failure
390+
* `'CRL_SIGNATURE_FAILURE'`: CRL signature failure
391+
* `'CERT_NOT_YET_VALID'`: certificate is not yet valid
392+
* `'CERT_HAS_EXPIRED'`: certificate has expired
393+
* `'CRL_NOT_YET_VALID'`: CRL is not yet valid
394+
* `'CRL_HAS_EXPIRED'`: CRL has expired
395+
* `'ERROR_IN_CERT_NOT_BEFORE_FIELD'`: format error in certificate's notBefore field
396+
* `'ERROR_IN_CERT_NOT_AFTER_FIELD'`: format error in certificate's notAfter field
397+
* `'ERROR_IN_CRL_LAST_UPDATE_FIELD'`: format error in CRL's lastUpdate field
398+
* `'ERROR_IN_CRL_NEXT_UPDATE_FIELD'`: format error in CRL's nextUpdate field
399+
* `'OUT_OF_MEM'`: out of memory
400+
* `'DEPTH_ZERO_SELF_SIGNED_CERT'`: self signed certificate
401+
* `'SELF_SIGNED_CERT_IN_CHAIN'`: self signed certificate in certificate chain
402+
* `'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'`: unable to get local issuer certificate
403+
* `'UNABLE_TO_VERIFY_LEAF_SIGNATURE'`: unable to verify the first certificate
404+
* `'CERT_CHAIN_TOO_LONG'`: certificate chain too long
405+
* `'CERT_REVOKED'`: certificate revoked
406+
* `'INVALID_CA'`: invalid CA certificate
407+
* `'PATH_LENGTH_EXCEEDED'`: path length constraint exceeded
408+
* `'INVALID_PURPOSE'`: unsupported certificate purpose
409+
* `'CERT_UNTRUSTED'`: certificate not trusted
410+
* `'CERT_REJECTED'`: certificate rejected
411+
* `'HOSTNAME_MISMATCH'`: Hostname mismatch
412+
413+
373414
## Class: `tls.CryptoStream`
374415
<!-- YAML
375416
added: v0.3.4

src/crypto/crypto_common.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ const char* X509ErrorCode(long err) { // NOLINT(runtime/int)
297297
const char* code = "UNSPECIFIED";
298298
#define CASE_X509_ERR(CODE) case X509_V_ERR_##CODE: code = #CODE; break;
299299
switch (err) {
300+
// if you modify anything in here, *please* update the respective section in
301+
// doc/api/tls.md as well
300302
CASE_X509_ERR(UNABLE_TO_GET_ISSUER_CERT)
301303
CASE_X509_ERR(UNABLE_TO_GET_CRL)
302304
CASE_X509_ERR(UNABLE_TO_DECRYPT_CERT_SIGNATURE)

0 commit comments

Comments
 (0)