/
template.go
36 lines (31 loc) · 1 KB
/
template.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
package simplecertify
import (
"crypto/x509"
"crypto/x509/pkix"
"math/big"
"time"
)
func CATemplate() x509.Certificate {
template := x509.Certificate{
SerialNumber: big.NewInt(2019),
Subject: pkix.Name{Organization: []string{"SimpleCertify CA"}},
NotBefore: time.Now(),
NotAfter: time.Now().AddDate(1, 0, 0),
IsCA: true,
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
BasicConstraintsValid: true,
}
return template
}
func ServerTemplate() x509.Certificate {
template := x509.Certificate{
SerialNumber: big.NewInt(2019),
Subject: pkix.Name{Organization: []string{"SimpleCertify Server"}},
NotBefore: time.Now(),
NotAfter: time.Now().AddDate(1, 0, 0),
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
KeyUsage: x509.KeyUsageDigitalSignature,
}
return template
}