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 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