cacert-gosigner/x509/signing/signer.go

65 lines
1.3 KiB
Go

package signing
import (
"crypto/x509"
"crypto/x509/pkix"
"time"
)
type SignerRequest struct {
csr *x509.CertificateRequest
subjectDN pkix.Name
emails []string
dnsNames []string
duration time.Duration
signatureAlgorithm x509.SignatureAlgorithm
}
func (s *SignerRequest) SignatureAlgorithm() x509.SignatureAlgorithm {
return s.signatureAlgorithm
}
func (s *SignerRequest) Duration() time.Duration {
return s.duration
}
func (s *SignerRequest) DnsNames() []string {
return s.dnsNames
}
func (s *SignerRequest) Emails() []string {
return s.emails
}
func (s *SignerRequest) Csr() *x509.CertificateRequest {
return s.csr
}
func (s *SignerRequest) SubjectDN() pkix.Name {
return s.subjectDN
}
func NewSignerRequest(
csr *x509.CertificateRequest,
subjectDN pkix.Name,
emails, dnsNames []string,
duration time.Duration,
signatureAlgorithm x509.SignatureAlgorithm,
) *SignerRequest {
return &SignerRequest{
csr: csr,
subjectDN: subjectDN,
emails: emails,
dnsNames: dnsNames,
duration: duration,
signatureAlgorithm: signatureAlgorithm,
}
}
type SignerResponse interface {
Certificate() *x509.Certificate
}
type Signer interface {
SignCertificate(*SignerRequest) (SignerResponse, error)
}