SSL_CHECK_CHAIN(3ossl)
π SSL_CHECK_CHAIN β okay so bestie, let's check this chain
So this is a page from the OpenSSL manual, section 3ossl β yes, the crypto library your whole internet secretly runs on. We're doing SSL_check_chain, and honestly? She's giving "quietly important." π
β¨ NAME β¨
SSL_check_chain β check certificate chain suitability. That's it, that's the whole vibe check for your certs. π
π¦ SYNOPSIS π¦
#include <openssl/ssl.h>
int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain);
Like, four args, no notes. Copy it exactly, bestie, don't get creative. β¨
πΈ DESCRIPTION πΈ
So SSL_check_chain() literally just 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 the whole thing. She's a "is this outfit okay for this party" function, but for cryptography. π«Ά
π RETURN VALUES π
SSL_check_chain() hands you back a bitmap of flags β a little handful of yes/no stickers telling you whether the chain is valid. Let's go through them one by one, no skips:
CERT_PKEY_VALIDβ the chain can be used with the current session. π₯ And listen: if this flag is not set, the certificate will never be used, even if your app tries to set it, because it's inconsistent with the peer's preferences. Not negotiable, not up for discussion. Periodt.CERT_PKEY_SIGNβ the EE key can be used for signing. πCERT_PKEY_EE_SIGNATUREβ the signature algorithm of the EE certificate is acceptable. Slay.CERT_PKEY_CA_SIGNATUREβ the signature algorithms of all the CA certificates are acceptable. All of them. The whole committee agreed. π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's mentioned in the signature algorithms extension. iykyk. β¨CERT_PKEY_ISSUER_NAMEβ the issuer name is acceptable. Heads up though: this one's only meaningful for client authentication. πCERT_PKEY_CERT_TYPEβ the certificate type is acceptable. Again, only meaningful for client authentication. πCERT_PKEY_SUITEBβ the chain is suitable for Suite B use. Fancy. π
π NOTES π
Okay so timing matters here, bestie:
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 in the certificate callback. Like, it's a "read the room first" situation. π«Ά
If your app wants to support multiple certificate chains, you can call this function on each chain in turn β starting with the one you consider the most secure β and then just use the chain from the first set that returns suitable flags. Iconic, efficient, no cap. β¨
At minimum, CERT_PKEY_VALID must be set for a chain to be usable. That's the bare minimum, that's the entry fee. π
If your app supports multiple chains with different CA signature algorithms, you might also wanna 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. Fallback queen behavior. π
How is a chain's validity even determined? By checking if it matches a supported signature algorithm, supported curves, and β in the case of client authentication β certificate types and issuer names. πΈ
β οΈ Real talk: 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. Consider this your heads-up.
π§ SEE ALSO π§
Go read those too, bestie, they're part of the lore. π
π 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 little gem is from OpenSSL version 3.5.0, dated 2026-09-25, and it lives at SSL_CHECK_CHAIN(3ossl) in the manual. Go forth and validate those chains β responsibly. πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms