Currently, the tls_boring module incorrectly passes a PEM-encoded
private key file to boring::PKey::private_key_from_pkcs8, which
expects a single DER-encoded PKCS#8 private key. This fails, because the
PEM file's contents is PEM-encoded, rather than DER-encoded. The test
added in 9187fb89e201062e80083f9ebd6532b39491f940 reproduces this
failure.
This PR changes the tls_boring module to use
PKey::private_key_from_pem instead of PKey::private_key_from_pkcs8,
which correctly parses the PEM-encoded private key file contents.
We may wish to consider making this code smarter and determining the
input file format based on the filename extension, so that we can handle
private key files with different encodings. But, the rustls
implementation currently assumes that the private key file is always
PEM-encoded, so that's probably better saved for future work.
Currently, the
tls_boring
module incorrectly passes a PEM-encoded private key file toboring::PKey::private_key_from_pkcs8
, which expects a single DER-encoded PKCS#8 private key. This fails, because the PEM file's contents is PEM-encoded, rather than DER-encoded. The test added in 9187fb89e201062e80083f9ebd6532b39491f940 reproduces this failure.This PR changes the
tls_boring
module to usePKey::private_key_from_pem
instead ofPKey::private_key_from_pkcs8
, which correctly parses the PEM-encoded private key file contents.We may wish to consider making this code smarter and determining the input file format based on the filename extension, so that we can handle private key files with different encodings. But, the
rustls
implementation currently assumes that the private key file is always PEM-encoded, so that's probably better saved for future work.