Skip to content

Commit

Permalink
crypto/x509: remove leftover CertificateRequest field
Browse files Browse the repository at this point in the history
Removes the KeyUsage field that was missed in the rollback in
CL 281235.
Also updates CreateCertificateRequest to reflect that these fields
were removed.

For #43407.
Updates #43477.
Updates #37172.

Change-Id: I6244aed4a3ef3c2460c38af5511e5c2e82546179
Reviewed-on: https://go-review.googlesource.com/c/go/+/287392
Trust: Alexander Rakoczy <alex@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
  • Loading branch information
rolandshoemaker committed Jan 27, 2021
1 parent a5a5e2c commit 35334ca
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
24 changes: 0 additions & 24 deletions src/crypto/x509/x509.go
Original file line number Diff line number Diff line change
Expand Up @@ -1997,15 +1997,6 @@ func buildCSRExtensions(template *CertificateRequest) ([]pkix.Extension, error)
})
}

if template.KeyUsage != 0 &&
!oidInExtensions(oidExtensionKeyUsage, template.ExtraExtensions) {
ext, err := marshalKeyUsage(template.KeyUsage)
if err != nil {
return nil, err
}
ret = append(ret, ext)
}

return append(ret, template.ExtraExtensions...), nil
}

Expand Down Expand Up @@ -2371,7 +2362,6 @@ type CertificateRequest struct {
Version int
Signature []byte
SignatureAlgorithm SignatureAlgorithm
KeyUsage KeyUsage

PublicKeyAlgorithm PublicKeyAlgorithm
PublicKey interface{}
Expand Down Expand Up @@ -2501,15 +2491,6 @@ func parseCSRExtensions(rawAttributes []asn1.RawValue) ([]pkix.Extension, error)
// - EmailAddresses
// - IPAddresses
// - URIs
// - KeyUsage
// - ExtKeyUsage
// - UnknownExtKeyUsage
// - BasicConstraintsValid
// - IsCA
// - MaxPathLen
// - MaxPathLenZero
// - SubjectKeyId
// - PolicyIdentifiers
// - ExtraExtensions
// - Attributes (deprecated)
//
Expand Down Expand Up @@ -2734,11 +2715,6 @@ func parseCertificateRequest(in *certificateRequest) (*CertificateRequest, error
if err != nil {
return nil, err
}
case extension.Id.Equal(oidExtensionKeyUsage):
out.KeyUsage, err = parseKeyUsageExtension(extension.Value)
if err != nil {
return nil, err
}
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/crypto/x509/x509_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2977,7 +2977,6 @@ func TestCertificateRequestRoundtripFields(t *testing.T) {
EmailAddresses: []string{"a@example.com", "b@example.com"},
IPAddresses: []net.IP{net.IPv4(192, 0, 2, 0), net.IPv6loopback},
URIs: []*url.URL{urlA, urlB},
KeyUsage: KeyUsageCertSign,
}
out := marshalAndParseCSR(t, in)

Expand All @@ -2995,7 +2994,4 @@ func TestCertificateRequestRoundtripFields(t *testing.T) {
if !reflect.DeepEqual(in.URIs, out.URIs) {
t.Fatalf("Unexpected URIs: got %v, want %v", out.URIs, in.URIs)
}
if in.KeyUsage != out.KeyUsage {
t.Fatalf("Unexpected KeyUsage: got %v, want %v", out.KeyUsage, in.KeyUsage)
}
}

0 comments on commit 35334ca

Please sign in to comment.