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
22 lines
411 B
Go
22 lines
411 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package parsing
|
|
|
|
import (
|
|
"encoding/pem"
|
|
"errors"
|
|
"strings"
|
|
)
|
|
|
|
func DecodePem(certBytes []byte) (*pem.Block, error) {
|
|
block, extra := pem.Decode(certBytes)
|
|
if block == nil {
|
|
return nil, errors.New("invalid PEM")
|
|
}
|
|
if len(strings.TrimSpace(string(extra))) > 0 {
|
|
return nil, errors.New("trailing PEM data")
|
|
}
|
|
return block, nil
|
|
}
|