Skip to content

Commit

Permalink
Rename struct from MiniCA to CA.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraino committed Mar 16, 2022
1 parent 1ff8afd commit 99fbede
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions minica/minica.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"golang.org/x/crypto/ssh"
)

// MiniCA is the implementation of a simple X.509 and SSH CA.
type MiniCA struct {
// CA is the implementation of a simple X.509 and SSH CA.
type CA struct {
Root *x509.Certificate
Intermediate *x509.Certificate
Signer crypto.Signer
Expand All @@ -22,7 +22,7 @@ type MiniCA struct {

// New creates a new MiniCA, the custom options allows to overwrite templates,
// signer types and certificate names.
func New(opts ...Option) (*MiniCA, error) {
func New(opts ...Option) (*CA, error) {
now := time.Now()
o := newOptions().apply(opts)

Expand Down Expand Up @@ -90,7 +90,7 @@ func New(opts ...Option) (*MiniCA, error) {
return nil, err
}

return &MiniCA{
return &CA{
Root: root,
Intermediate: intermediate,
Signer: intSigner,
Expand All @@ -100,7 +100,7 @@ func New(opts ...Option) (*MiniCA, error) {
}

// Sign signs an X.509 certificate template using the intermediate certificate.
func (c *MiniCA) Sign(template *x509.Certificate) (*x509.Certificate, error) {
func (c *CA) Sign(template *x509.Certificate) (*x509.Certificate, error) {
if template.NotBefore.IsZero() {
template.NotBefore = time.Now()
}
Expand All @@ -111,7 +111,7 @@ func (c *MiniCA) Sign(template *x509.Certificate) (*x509.Certificate, error) {
}

// SignCSR signs an X.509 certificate signing request. The custom options allows to change the template used for
func (c *MiniCA) SignCSR(csr *x509.CertificateRequest, opts ...SignOption) (*x509.Certificate, error) {
func (c *CA) SignCSR(csr *x509.CertificateRequest, opts ...SignOption) (*x509.Certificate, error) {
sans := append([]string{}, csr.DNSNames...)
sans = append(sans, csr.EmailAddresses...)
for _, ip := range csr.IPAddresses {
Expand All @@ -138,7 +138,7 @@ func (c *MiniCA) SignCSR(csr *x509.CertificateRequest, opts ...SignOption) (*x50
}

// SignSSH signs an SSH host or user certificate.
func (c *MiniCA) SignSSH(cert *ssh.Certificate) (*ssh.Certificate, error) {
func (c *CA) SignSSH(cert *ssh.Certificate) (*ssh.Certificate, error) {
if cert.ValidAfter == 0 {
cert.ValidAfter = uint64(time.Now().Unix())
}
Expand Down
8 changes: 4 additions & 4 deletions minica/minica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (c mockConnMetadata) LocalAddr() net.Addr {
return &net.IPAddr{IP: net.IP{1, 2, 3, 4}}
}

func mustCA(t *testing.T, opts ...Option) *MiniCA {
func mustCA(t *testing.T, opts ...Option) *CA {
t.Helper()
ca, err := New(opts...)
if err != nil {
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestMiniCA_Sign(t *testing.T) {
}
tests := []struct {
name string
ca *MiniCA
ca *CA
args args
wantErr bool
}{
Expand Down Expand Up @@ -240,7 +240,7 @@ func TestMiniCA_SignCSR(t *testing.T) {
}
tests := []struct {
name string
ca *MiniCA
ca *CA
args args
wantDNSName string
wantKeyUsages []x509.ExtKeyUsage
Expand Down Expand Up @@ -302,7 +302,7 @@ func TestMiniCA_SignSSH(t *testing.T) {
}
tests := []struct {
name string
ca *MiniCA
ca *CA
args args
wantCertType uint32
wantPrincipal string
Expand Down

0 comments on commit 99fbede

Please sign in to comment.