X509_CHECK_PRIVATE_KEY(3ossl)
π NAME π
okay bestie, welcome to the X509_CHECK_PRIVATE_KEY(3ossl) manual page from OpenSSL π the main characters are X509_check_private_key and X509_REQ_check_private_key β they check the consistency of a private key with the public key in an X509 certificate or certificate request. periodt. π
β¨ SYNOPSIS β¨
#include <openssl/x509.h>
int X509_check_private_key(const X509 *cert, EVP_PKEY *pkey);
int X509_REQ_check_private_key(X509_REQ *req, EVP_PKEY *pkey);
π¦ DESCRIPTION π¦
X509_check_private_key() function checks the consistency of private key pkey with the public key in cert. that's the whole vibe check π«Ά
X509_REQ_check_private_key() is equivalent to X509_check_private_key() except that req represents a certificate request of structure X509_REQ. literally same energy, different wrapper β¨
πΈ RETURN VALUES πΈ
X509_check_private_key() and X509_REQ_check_private_key() return 1 if the keys match each other, and 0 if not. slay or no slay, no in-between π
If the key is invalid or an error occurred, the reason code can be obtained using ERR_get_error(3). go grab the receipts π₯
π BUGS π
okay this is the important caveat bestie, do not skip it π
The X509_check_private_key() and X509_REQ_check_private_key() functions do not check if pkey itself is indeed a private key or not. They merely compare the public materials (e.g., exponent and modulus of an RSA key) and/or key parameters (e.g. EC params of an EC key) of a key pair. So they also return success if pkey is a matching public key.
so yeah β this is giving βmatch confirmedβ not βprivate key confirmedβ π keep that in mind, fr fr.
π SEE ALSO π
ERR_get_error(3)β the one to hit up when you need the reason code.
π COPYRIGHT π
Copyright 2017-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>.
this page is from OpenSSL 3.5.0, dated 2026-09-25, and it's the X509_CHECK_PRIVATE_KEY(3ossl) manual β bye bestie! π
β¨π«Ά
π¦ 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