SSL_CHECK_CHAIN(3SSL)
β¨ SSL_CHECK_CHAIN π β like, the OpenSSL manual, page 3SSL, bestie
okay so you found the SSL_check_chain page in the OpenSSL docs (section 3SSL, yes we're in the library-functions section, iykyk) and honestly? this one's a bop. it's all about asking "hey, is this cert chain actually gonna work for this session" before you commit. no cap.
πΈ NAME πΈ
SSL_check_chain β check certificate chain suitability π
π¦ SYNOPSIS π¦
#include <openssl/ssl.h>
int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain);
π DESCRIPTION π
so SSL_check_chain() is literally just vibe-checking your setup: it checks whether the certificate x, the private key pk, and the certificate chain chain are suitable for use with the current session s. that's it. that's the function. β¨
π RETURN VALUES π
SSL_check_chain() hands you back a bitmap of flags β like a little report card π β telling you how valid the chain is. here's the whole lineup, bestie, don't skip any:
CERT_PKEY_VALIDβ the chain can be used with the current session. and listen: if this flag is not set, then the certificate will never be used, even if the application tries to set it, because it's inconsistent with the peer preferences. so likeβ¦ if this one's missing, it's over. πCERT_PKEY_SIGNβ the EE key can be used for signing.CERT_PKEY_EE_SIGNATUREβ the signature algorithm of the EE certificate is acceptable.CERT_PKEY_CA_SIGNATUREβ the signature algorithms of all CA certificates are acceptable.CERT_PKEY_EE_PARAMβ the parameters of the end entity certificate are acceptable (e.g. it's a supported curve). πCERT_PKEY_CA_PARAMβ the parameters of all CA certificates are acceptable.CERT_PKEY_EXPLICIT_SIGNβ the end entity certificate algorithm can be used explicitly for signing (i.e. it is mentioned in the signature algorithms extension).CERT_PKEY_ISSUER_NAMEβ the issuer name is acceptable. this one is only meaningful for client authentication.CERT_PKEY_CERT_TYPEβ the certificate type is acceptable. again, only meaningful for client authentication.CERT_PKEY_SUITEBβ chain is suitable for Suite B use.
π§ NOTES π§
okay important timing tea β β SSL_check_chain() must be called in servers after a client hello message, or in clients after a certificate request message. typically you'd call it inside the certificate callback. that's the move. π«Ά
if your app wants to support multiple certificate chains, you can just call this function on each chain in turn, starting with the one you consider the most secure, and then use the chain of the first set that returns suitable flags. first one to pass the vibe check wins. π
as a minimum, the flag CERT_PKEY_VALID must be set for a chain to be usable. and if your application is supporting multiple chains with different CA signature algorithms, you may also want to check CERT_PKEY_CA_SIGNATURE too. and if no chain is suitable? a server should fall back to the most secure chain which sets CERT_PKEY_VALID.
the validity of a chain gets determined by checking if it matches a supported signature algorithm, supported curves, and β in the case of client authentication β certificate types and issuer names. β
and here's a lil caveat, because context matters: since the supported signature algorithms extension is only used in TLS 1.2, TLS 1.3 and DTLS 1.2, the results for earlier versions of TLS and DTLS may not be very useful. π applications may wish to specify a different "legacy" chain for earlier versions of TLS or DTLS.
fr fr, don't @ me about pre-1.2 results, the extension literally isn't there.
π SEE ALSO π
π COPYRIGHT π
Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page, bestie π β this was OpenSSL version 4.0.3, dated 2026-09-29, page SSL_CHECK_CHAIN(3SSL). slay, go check those chains. π
β¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms