Implement Common Name

This commit is contained in:
raul 2024-06-03 11:23:10 +02:00
parent 582f130e44
commit 5ef620205d
2 changed files with 5 additions and 2 deletions

View File

@ -8,6 +8,7 @@ street_address = "C/Fake Address 123"
postal_code = "46250" postal_code = "46250"
not_after = 10 not_after = 10
rsa_bitsize = 3072 rsa_bitsize = 3072
common_name = "empresa.com"
[Server] [Server]
port = "1302" port = "1302"

View File

@ -30,6 +30,7 @@ var (
postalcode string postalcode string
notafter int notafter int
RSA_bitsize int RSA_bitsize int
commonname string
) )
func generateCA() { func generateCA() {
@ -47,8 +48,7 @@ func generateCA() {
streetaddress = viper.GetString("CA.street_address") streetaddress = viper.GetString("CA.street_address")
postalcode = viper.GetString("CA.postal_code") postalcode = viper.GetString("CA.postal_code")
notafter = viper.GetInt("CA.not_after") notafter = viper.GetInt("CA.not_after")
// fmt.Println(serialnumber, organization, country, province, locality, streetaddress, postalcode, notafter) commonname = viper.GetString("CA.common_name")
// os.Exit(0)
ca := &x509.Certificate{ ca := &x509.Certificate{
SerialNumber: big.NewInt(int64(serialnumber)), SerialNumber: big.NewInt(int64(serialnumber)),
@ -59,6 +59,7 @@ func generateCA() {
Locality: []string{locality}, Locality: []string{locality},
StreetAddress: []string{streetaddress}, StreetAddress: []string{streetaddress},
PostalCode: []string{postalcode}, PostalCode: []string{postalcode},
CommonName: commonname,
}, },
NotBefore: time.Now(), NotBefore: time.Now(),
NotAfter: time.Now().AddDate(notafter, 0, 0), NotAfter: time.Now().AddDate(notafter, 0, 0),
@ -148,6 +149,7 @@ func generateCert(serNumber int, clientOrg string, clientCountry string,
Locality: []string{clientLocality}, Locality: []string{clientLocality},
StreetAddress: []string{clientStreetAddr}, StreetAddress: []string{clientStreetAddr},
PostalCode: []string{clientPostCode}, PostalCode: []string{clientPostCode},
CommonName: clientDomain,
}, },
DNSNames: []string{clientDomain}, DNSNames: []string{clientDomain},
NotBefore: time.Now(), NotBefore: time.Now(),