Update CertificateFromPEM to support OpenSSL

Update CertificateFromPEM to be a loop over the PEM blocks.
This allows decoding the private key before decoding the certificate.
Tries to parse the certificate block directly but if that errors, then it also
tries to base64 decode the certificate block.

Fixes #3042
This commit is contained in:
Evan Brass
2025-03-09 09:44:10 -07:00
committed by Sean DuBois
parent e4ff415b2b
commit 63b1f799b3
3 changed files with 105 additions and 27 deletions

View File

@@ -275,7 +275,9 @@ var (
errICETransportNotInNew = errors.New("ICETransport can only be called in ICETransportStateNew")
errICETransportClosed = errors.New("ICETransport closed")
errCertificatePEMFormatError = errors.New("bad Certificate PEM format")
errCertificatePEMMultipleCert = errors.New("failed parsing certificate, more than 1 CERTIFICATE block in pems")
errCertificatePEMMultiplePriv = errors.New("failed parsing certificate, more than 1 PRIVATE KEY block in pems")
errCertificatePEMMissing = errors.New("failed parsing certificate, pems must contain both a CERTIFICATE block and a PRIVATE KEY block") // nolint: lll
errRTPTooShort = errors.New("not long enough to be a RTP Packet")