Verify with roots and intermediates

This commit is contained in:
Mariano Cano 2022-08-30 17:11:44 -07:00
parent 30c54a555d
commit a7fcfe0e4e

View file

@ -489,11 +489,14 @@ func TestSoftCAS_CreateCertificate_ec_rsa(t *testing.T) {
t.Errorf("Certificate.SignatureAlgorithm = %v, want %v", iss.SignatureAlgorithm, x509.SHA256WithRSAPSS) t.Errorf("Certificate.SignatureAlgorithm = %v, want %v", iss.SignatureAlgorithm, x509.SHA256WithRSAPSS)
} }
pool := x509.NewCertPool() roots := x509.NewCertPool()
pool.AddCert(iss) roots.AddCert(root)
intermediates := x509.NewCertPool()
intermediates.AddCert(iss)
if _, err = cert.Certificate.Verify(x509.VerifyOptions{ if _, err = cert.Certificate.Verify(x509.VerifyOptions{
CurrentTime: time.Now(), CurrentTime: time.Now(),
Roots: pool, Roots: roots,
Intermediates: intermediates,
KeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth}, KeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
}); err != nil { }); err != nil {
t.Errorf("Certificate.Verify() error = %v", err) t.Errorf("Certificate.Verify() error = %v", err)