@@ -14,6 +14,8 @@ import (
1414 "fmt"
1515 "math/big"
1616 "time"
17+
18+ "github.com/tschaefer/finchctl/internal/version"
1719)
1820
1921const CertValidityDays = 90 * 24 * time .Hour
@@ -30,11 +32,8 @@ func GenerateCA(hostname string) ([]byte, []byte, error) {
3032 }
3133
3234 template := x509.Certificate {
33- SerialNumber : serialNumber ,
34- Subject : pkix.Name {
35- Organization : []string {"Finch" },
36- CommonName : fmt .Sprintf ("Finch CA - %s" , hostname ),
37- },
35+ SerialNumber : serialNumber ,
36+ Subject : pkix.Name {CommonName : hostname },
3837 NotBefore : time .Now (),
3938 NotAfter : time .Now ().Add (CertValidityDays ),
4039 KeyUsage : x509 .KeyUsageCertSign | x509 .KeyUsageCRLSign | x509 .KeyUsageDigitalSignature ,
@@ -95,14 +94,11 @@ func GenerateClient(hostname string, caCertPEM, caKeyPEM []byte) ([]byte, []byte
9594
9695 template := x509.Certificate {
9796 SerialNumber : serialNumber ,
98- Subject : pkix.Name {
99- Organization : []string {"Finch" },
100- CommonName : fmt .Sprintf ("Finch Client - %s" , hostname ),
101- },
102- NotBefore : time .Now (),
103- NotAfter : time .Now ().Add (CertValidityDays ),
104- KeyUsage : x509 .KeyUsageDigitalSignature ,
105- ExtKeyUsage : []x509.ExtKeyUsage {x509 .ExtKeyUsageClientAuth },
97+ Subject : pkix.Name {CommonName : version .ResourceID ()},
98+ NotBefore : time .Now (),
99+ NotAfter : time .Now ().Add (CertValidityDays ),
100+ KeyUsage : x509 .KeyUsageDigitalSignature ,
101+ ExtKeyUsage : []x509.ExtKeyUsage {x509 .ExtKeyUsageClientAuth },
106102 }
107103
108104 clientCertDER , err := x509 .CreateCertificate (rand .Reader , & template , caCert , & clientKey .PublicKey , caKey )
0 commit comments