mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-11 00:57:00 +02:00
* PKI refactoring to start breaking apart monolith into sub-packages - This was broken down by commit within enterprise for ease of review but would be too difficult to bring back individual commits back to the CE repository. (they would be squashed anyways) - This change was created by exporting a patch of the enterprise PR and applying it to CE repository * Fix TestBackend_OID_SANs to not be rely on map ordering
28 lines
664 B
Go
28 lines
664 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package parsing
|
|
|
|
import (
|
|
"crypto/x509"
|
|
"fmt"
|
|
)
|
|
|
|
func ParseCertificateRequestFromString(pemCert string) (*x509.CertificateRequest, error) {
|
|
return ParseCertificateRequestFromBytes([]byte(pemCert))
|
|
}
|
|
|
|
func ParseCertificateRequestFromBytes(certBytes []byte) (*x509.CertificateRequest, error) {
|
|
block, err := DecodePem(certBytes)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("unable to parse certificate request: %w", err)
|
|
}
|
|
|
|
csr, err := x509.ParseCertificateRequest(block.Bytes)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("unable to parse certificate request: %w", err)
|
|
}
|
|
|
|
return csr, nil
|
|
}
|