Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloudAgent changes for HyperV-Socket CAs certificates #194

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/certs/certificateAuthority.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ func (ca *CertificateAuthority) SignRequest(csrPem []byte, oldCertPem []byte, co
extKeyUsage = append(extKeyUsage, x509.ExtKeyUsageServerAuth)
}

if conf != nil && conf.IsCA {
keyUsage |= x509.KeyUsageCertSign
}

csr, err := DecodeCertRequestPEM(csrPem)
if err != nil {
return
Expand All @@ -185,9 +189,11 @@ func (ca *CertificateAuthority) SignRequest(csrPem []byte, oldCertPem []byte, co

offset := (time.Hour * 24 * 365)
accessIdentity := []byte{}
isCA := false
if conf != nil {
offset = conf.Offset
accessIdentity = []byte(conf.Identity)
isCA = conf.IsCA
}
now := time.Now().UTC()

Expand All @@ -201,6 +207,8 @@ func (ca *CertificateAuthority) SignRequest(csrPem []byte, oldCertPem []byte, co
BasicConstraintsValid: true,
DNSNames: csr.DNSNames,
IPAddresses: csr.IPAddresses,
IsCA: isCA,
MaxPathLenZero: isCA, // Enable MaxPathLenZero only when is CA
}

csrRenewCertsPEM := []byte{}
Expand Down
1 change: 1 addition & 0 deletions pkg/certs/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type SignConfig struct {
Offset time.Duration
Identity string
ServerAuth bool
IsCA bool
}

// AltNames contains the domain names and IP addresses for a cert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ message CertificateSigningRequest {
string locationName = 8;
string identity = 9;
int64 validity = 10;
google.protobuf.BoolValue isCA = 11;
}

message Certificate {
Expand Down
119 changes: 64 additions & 55 deletions rpc/cloudagent/security/moc_cloudagent_certificate.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.