-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathself_signer.go
29 lines (26 loc) · 914 Bytes
/
self_signer.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
package selfsignedcertgen
import "time"
// Struct containing parameters for key and certificate generation
type SelfSigner struct {
Country string
Hosts []string // first host will be used as CN, all hosts will be added as SAN
Locality string
Organization string
OrganizationUnit string
RsaKeyBits int // default: 2048
ValidFor time.Duration // duraation after ValidFrom the certificate will be valid
ValidFrom time.Time // earliest date for certificate validity
}
// Create a new SelfSigner struct with dummy values
func NewSelfSigner() *SelfSigner {
ss := new(SelfSigner)
ss.Country = "JP"
ss.Hosts = []string{"www.example.com"}
ss.Locality = "Calpamos"
ss.Organization = "Weyland Yutani"
ss.OrganizationUnit = "Special Services"
ss.RsaKeyBits = 2048
ss.ValidFrom = time.Now()
ss.ValidFor = 365 * 24 * time.Hour
return ss
}