---
name: "libressl-X509_check_private_key"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-X509_check_private_key"
---

# libressl-X509\_check\_private\_key(3)

compare public key components

## NAME

**X509\_check\_private\_key**, **X509\_REQ\_check\_private\_key** – compare public key components

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/x509.h\>**

*int*\

**X509\_check\_private\_key**(*const X509 \*x*, *const EVP\_PKEY \*k*);

*int*\

**X509\_REQ\_check\_private\_key**(*X509\_REQ \*x*, *EVP\_PKEY \*k*);

## DESCRIPTION

These functions are seriously misnamed. **X509\_check\_private\_key**() compares the *public* key components (e.g. exponent and modulus of an RSA key) and parameters (e.g. EC params of an EC key) of *k* with the corresponding properties of *x*. Despite the name, it neither checks whether *k* contains private key components at all, nor, if any are present, whether they are consistent with the public key components.

**X509\_REQ\_check\_private\_key**() is equivalent to **X509\_check\_private\_key**() except that it compares to the public key contained in a certificate request.

## RETURN VALUES

These functions return 1 if the public key components and parameters match, or 0 if they do not or if an error occurs. On error or mismatch, a reason code can be obtained using ERR\_get\_error(3).

## SEE ALSO

SSL\_check\_private\_key(3), X509\_new(3), X509\_REQ\_new(3)

## HISTORY

**X509\_check\_private\_key**() first appeared in SSLeay 0.6.5 and has been available since OpenBSD 2.4.

**X509\_REQ\_check\_private\_key**() first appeared in OpenSSL 0.9.8 and has been available since OpenBSD 4.5.
