2020-09-08 19:26:32 -07:00
|
|
|
package apiv1
|
|
|
|
|
2020-09-10 16:19:18 -07:00
|
|
|
import (
|
|
|
|
"encoding/asn1"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
oidStepRoot = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 37476, 9000, 64}
|
|
|
|
oidStepCertificateAuthority = append(asn1.ObjectIdentifier(nil), append(oidStepRoot, 2)...)
|
|
|
|
)
|
|
|
|
|
2020-09-08 19:26:32 -07:00
|
|
|
// CertificateAuthorityService is the interface implemented to support external
|
|
|
|
// certificate authorities.
|
|
|
|
type CertificateAuthorityService interface {
|
|
|
|
CreateCertificate(req *CreateCertificateRequest) (*CreateCertificateResponse, error)
|
|
|
|
RenewCertificate(req *RenewCertificateRequest) (*RenewCertificateResponse, error)
|
|
|
|
RevokeCertificate(req *RevokeCertificateRequest) (*RevokeCertificateResponse, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Type represents the KMS type used.
|
|
|
|
type Type string
|
|
|
|
|
|
|
|
const (
|
|
|
|
// DefaultCAS is a CertificateAuthorityService using software.
|
|
|
|
DefaultCAS = ""
|
|
|
|
// SoftCAS is a CertificateAuthorityService using software.
|
2020-09-10 16:19:18 -07:00
|
|
|
SoftCAS = "SoftCAS"
|
2020-09-08 19:26:32 -07:00
|
|
|
// CloudCAS is a CertificateAuthorityService using Google Cloud CAS.
|
2020-09-10 16:19:18 -07:00
|
|
|
CloudCAS = "CloudCAS"
|
2020-09-08 19:26:32 -07:00
|
|
|
)
|
2020-09-10 16:19:18 -07:00
|
|
|
|
|
|
|
// String returns the given type as a string. All the letters will be lowercase.
|
|
|
|
func (t Type) String() string {
|
|
|
|
if t == "" {
|
|
|
|
return SoftCAS
|
|
|
|
}
|
|
|
|
for _, s := range []string{SoftCAS, CloudCAS} {
|
|
|
|
if strings.EqualFold(s, string(t)) {
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return string(t)
|
|
|
|
}
|