# certMatchesPrivateKey

## Content

# Function: certMatchesPrivateKey()

```ts
function certMatchesPrivateKey(
   certPEM, 
   privateKeyPEM, 
   passphrase?): boolean;
```

Checks whether the public key inside an X.509 certificate matches a private key.

## Parameters

### certPEM

`string`

PEM-encoded X.509 certificate.

### privateKeyPEM

`string`

PEM-encoded private key (PKCS#1, PKCS#8, or SEC1).

### passphrase?

`string`

Passphrase, if the private key is encrypted.

## Returns

`boolean`

true if the cert's public key and the private key are a pair.
