-
Notifications
You must be signed in to change notification settings - Fork 0
/
roots.go
47 lines (38 loc) · 1.23 KB
/
roots.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package ca
import (
"crypto/x509"
"encoding/pem"
"fmt"
)
// ProductionRoots returns a CA EET root certificates for production purposes.
func ProductionRoots() ([]*x509.Certificate, error) {
cert, err := parseCert(RootCAEET1Production)
if err != nil {
return nil, fmt.Errorf("parse CA EET 1 Production certificate: %w", err)
}
cert2025, err := parseCert(RootCAEET1Production2025)
if err != nil {
return nil, fmt.Errorf("parse CA EET 1 Production 2025 certificate: %w", err)
}
return []*x509.Certificate{cert, cert2025}, nil
}
// PlaygroundRoots returns a CA EET root certificates for development purposes.
func PlaygroundRoots() ([]*x509.Certificate, error) {
cert, err := parseCert(RootCAEET1Playground)
if err != nil {
return nil, fmt.Errorf("parse CA EET 1 Playground certificate: %w", err)
}
cert2025, err := parseCert(RootCAEET1Playground2025)
if err != nil {
return nil, fmt.Errorf("parse CA EET 1 Playground 2025 certificate: %w", err)
}
return []*x509.Certificate{cert, cert2025}, nil
}
func parseCert(rawPEM []byte) (*x509.Certificate, error) {
block, _ := pem.Decode(rawPEM)
cert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
return nil, fmt.Errorf("parse certificate: %w", err)
}
return cert, nil
}