mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-28 07:57:20 +00:00
publish cluster authentication trust via controller
Kubernetes-commit: 7351c8686031b320f61c70fe065d3c039dda0a99
This commit is contained in:
parent
a537b3b527
commit
5aa4fef661
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package cert
|
package cert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"errors"
|
"errors"
|
||||||
@ -59,3 +60,14 @@ func ParseCertsPEM(pemCerts []byte) ([]*x509.Certificate, error) {
|
|||||||
}
|
}
|
||||||
return certs, nil
|
return certs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EncodeCertificates returns the PEM-encoded byte array that represents by the specified certs.
|
||||||
|
func EncodeCertificates(certs ...*x509.Certificate) ([]byte, error) {
|
||||||
|
b := bytes.Buffer{}
|
||||||
|
for _, cert := range certs {
|
||||||
|
if err := pem.Encode(&b, &pem.Block{Type: CertificateBlockType, Bytes: cert.Raw}); err != nil {
|
||||||
|
return []byte{}, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return b.Bytes(), nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user