-
Notifications
You must be signed in to change notification settings - Fork 1
/
structs.go
65 lines (57 loc) · 2.04 KB
/
structs.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package client
import (
"crypto/x509"
"errors"
)
const (
userAgent = "client.certsfor.dev"
)
// errors
var (
ErrUnknownError = errors.New("unknown error connecting to server")
ErrConnectionRefused = errors.New("connection refused")
)
// Certificate holds the certificate and key file used to interact with the
// data store
type Certificate struct {
Key []byte `json:"key,omitempty"`
Certificate []byte `json:"certificate,omitempty"`
CACertificate []byte `json:"ca_certificate,omitempty"`
X509Certificate *x509.Certificate `json:"-"`
Request APICertificateRequest `json:"request"`
CAID string `json:"ca_id,omitempty"`
}
// APICertificateRequest is the struct with the data needed to create a new
// certificate
type APICertificateRequest struct {
DN APIDN `json:"dn"`
SAN []string `json:"san" yaml:"san"` // SAN
Key string `json:"key" yaml:"key"` // Key Type (RSA/ECDSA):(complexity)
ExpirationDays int64 `json:"exp" yaml:"exp"` // Days the certificate will be valid
Client bool `json:"client" yaml:"client"` // requesting a client certificate?
}
// APIDN is the struct of a Distinguished Name
type APIDN struct {
CN string `json:"cn,omitempty" yaml:"cn"` // common name (required)
C string `json:"c,omitempty" yaml:"c"` // country
L string `json:"l,omitempty" yaml:"l"` // locality
O string `json:"o,omitempty" yaml:"o"` // organization
OU string `json:"ou,omitempty" yaml:"ou"` // organization unit
P string `json:"p,omitempty" yaml:"p"` // province
PC string `json:"pc,omitempty" yaml:"pc"` // postal code
ST string `json:"st,omitempty" yaml:"st"` // street
}
// key algorithms
const (
RSA2048 = "rsa:2048"
RSA3072 = "rsa:3072"
RSA4096 = "rsa:4096"
ECDSA224 = "ecdsa:224"
ECDSA256 = "ecdsa:256"
ECDSA384 = "ecdsa:384"
ECDSA521 = "ecdsa:521"
)
// APIStatus is returned by the API on GET /status
type APIStatus struct {
Version string `json:"version"`
}