pub fn read_key_from_pem(path: &Path) -> ProtoResult<PrivateKey>
Available on crate feature dns-over-rustls only.
Expand description

Attempts to read a private key from a PEM formatted file.

Accepted formats

  • DER-encoded plaintext RSA private key; as specified in PKCS#1/RFC3447
  • DER-encoded plaintext RSA private key; as specified in PKCS#8/RFC5958 default with openssl v3

Errors

Returns a ProtoError in either cases:

  • Unable to open key at given path
  • Encountered an IO error
  • Unable to read key: either no key or no key found in the right format