Fix and/or silence linter issues

This commit is contained in:
Herman Slatman
2024-10-01 14:26:49 +02:00
parent 45456591d6
commit bd4947121d
6 changed files with 19 additions and 11 deletions

View File

@@ -335,12 +335,12 @@ func (c *client) requestCertificate(t *testing.T, commonName string, sans []stri
}
var (
oidExtensionAuthorityKeyId = asn1.ObjectIdentifier{2, 5, 29, 35}
oidExtensionSubjectKeyId = asn1.ObjectIdentifier{2, 5, 29, 14}
oidExtensionAuthorityKeyID = asn1.ObjectIdentifier{2, 5, 29, 35}
oidExtensionSubjectKeyID = asn1.ObjectIdentifier{2, 5, 29, 14}
)
type authorityKeyId struct {
Id []byte `asn1:"optional,tag:0"`
type authorityKeyID struct {
ID []byte `asn1:"optional,tag:0"`
}
type pkcs1PublicKey struct {
@@ -367,12 +367,12 @@ func (c *client) requestCertificateEmulatingWindowsClient(t *testing.T, commonNa
// on Windows the self-signed certificate contains an authority key identifier
// extension that is marked critical
value, err := asn1.Marshal(authorityKeyId{[]byte("bla")}) // fake value
value, err := asn1.Marshal(authorityKeyID{[]byte("bla")}) // fake value
if err != nil {
return nil, fmt.Errorf("failed marshaling authority key ID")
}
authorityKeyIDExtension := pkix.Extension{
Id: oidExtensionAuthorityKeyId,
Id: oidExtensionAuthorityKeyID,
Critical: true,
Value: value,
}
@@ -387,15 +387,15 @@ func (c *client) requestCertificateEmulatingWindowsClient(t *testing.T, commonNa
}
h := sha1.Sum(publicKeyBytes)
subjectKeyId := h[:]
subjectKeyID := h[:]
// create subject key ID extension
value, err = asn1.Marshal(subjectKeyId)
value, err = asn1.Marshal(subjectKeyID)
if err != nil {
return nil, fmt.Errorf("failed marshaling subject key ID: %w", err)
}
subjectKeyIDExtension := pkix.Extension{
Id: oidExtensionSubjectKeyId,
Id: oidExtensionSubjectKeyID,
Value: value,
}

View File

@@ -4,7 +4,7 @@ It is based on Go 1.23, and has just the parts copied over required for
parsing X509 certificates.
The copy in this repository is intended to be used for preparing a SCEP request
emulating a Windows SCEP client. The Windows SCEP client markes the authority
emulating a Windows SCEP client. The Windows SCEP client marks the authority
key identifier as critical in the self-signed SCEP enrolment certificate, which
fails to parse using the standard X509 parser in Go 1.23 and later.
@@ -12,5 +12,4 @@ This is itself a copy from the copy in our PKCS7 package. We currently don't
intend to maintain that in an importable package, since we only need these copies
for testing purposes, hence needing another copy of the code.
*/
package legacyx509

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//nolint:stylecheck,revive,gocritic // code copied from crypto/x509
package legacyx509
import (

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//nolint:revive,gocritic,errorlint,unconvert // code copied from crypto/x509
package legacyx509
import (

View File

@@ -1,3 +1,8 @@
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//nolint:gocritic // code copied from crypto/x509
package legacyx509
import (

View File

@@ -18,6 +18,8 @@
// On macOS and Windows, certificate verification is handled by system APIs, but
// the package aims to apply consistent validation rules across operating
// systems.
//nolint:gosec,unused // code copied from crypto/x509
package legacyx509
import (