Update to Go 1.21
- bump go module version to 1.21 - replace deprecated CRL APIs - update dependencies
This commit is contained in:
parent
315d15a133
commit
2a800ecaf7
11 changed files with 91 additions and 96 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2022 CAcert Inc.
|
||||
Copyright 2022-2023 CAcert Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -114,7 +114,7 @@ func (g *TestCommandGenerator) GenerateCommands(ctx context.Context) error {
|
|||
},
|
||||
}
|
||||
|
||||
newRandomDuration := minSignInterval + time.Duration(mathRand.Int63n(int64(maxSignInterval)))
|
||||
newRandomDuration := minSignInterval + time.Duration(mathRand.Int63n(int64(maxSignInterval))) //nolint:gosec
|
||||
|
||||
signTimer.Reset(newRandomDuration)
|
||||
}
|
||||
|
|
12
go.mod
12
go.mod
|
@ -1,18 +1,18 @@
|
|||
module git.cacert.org/cacert-gosigner
|
||||
|
||||
go 1.17
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/ThalesIgnite/crypto11 v1.2.5
|
||||
github.com/balacode/go-delta v0.1.0
|
||||
github.com/dave/jennifer v1.6.0
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/dave/jennifer v1.7.0
|
||||
github.com/google/uuid v1.3.1
|
||||
github.com/justincpresley/go-cobs v1.3.1
|
||||
github.com/shamaton/msgpackgen v0.3.0
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/stretchr/testify v1.8.0
|
||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07
|
||||
golang.org/x/term v0.2.0
|
||||
golang.org/x/term v0.12.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
|
@ -24,5 +24,5 @@ require (
|
|||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/shamaton/msgpack/v2 v2.1.1 // indirect
|
||||
github.com/thales-e-security/pool v0.0.2 // indirect
|
||||
golang.org/x/sys v0.2.0 // indirect
|
||||
golang.org/x/sys v0.12.0 // indirect
|
||||
)
|
||||
|
|
51
go.sum
51
go.sum
|
@ -5,21 +5,14 @@ github.com/balacode/go-delta v0.1.0/go.mod h1:wLNrwTI3lHbPBvnLzqbHmA7HVVlm1u22XL
|
|||
github.com/balacode/zr v1.0.0/go.mod h1:pLeSAL3DhZ9L0JuiRkUtIX3mLOCtzBLnDhfmykbSmkE=
|
||||
github.com/balacode/zr v1.1.2 h1:DtZYCKtSTw8Giw/uv8zwkr2wb+C0Y7tx+947M077Ly0=
|
||||
github.com/balacode/zr v1.1.2/go.mod h1:hN/XmTlDUdBTg3nd6sfc65aCrdKpVd1Y4sTYInF+T+U=
|
||||
github.com/dave/astrid v0.0.0-20170323122508-8c2895878b14/go.mod h1:Sth2QfxfATb/nW4EsrSi2KyJmbcniZ8TgTaji17D6ms=
|
||||
github.com/dave/brenda v1.1.0/go.mod h1:4wCUr6gSlu5/1Tk7akE5X7UorwiQ8Rij0SKH3/BGMOM=
|
||||
github.com/dave/courtney v0.3.0/go.mod h1:BAv3hA06AYfNUjfjQr+5gc6vxeBVOupLqrColj+QSD8=
|
||||
github.com/dave/gopackages v0.0.0-20170318123100-46e7023ec56e/go.mod h1:i00+b/gKdIDIxuLDFob7ustLAVqhsZRk2qVZrArELGQ=
|
||||
github.com/dave/jennifer v1.4.1/go.mod h1:7jEdnm+qBcxl8PC0zyp7vxcpSRnzXSt9r39tpTVGlwA=
|
||||
github.com/dave/jennifer v1.6.0 h1:MQ/6emI2xM7wt0tJzJzyUik2Q3Tcn2eE0vtYgh4GPVI=
|
||||
github.com/dave/jennifer v1.6.0/go.mod h1:AxTG893FiZKqxy3FP1kL80VMshSMuz2G+EgvszgGRnk=
|
||||
github.com/dave/kerr v0.0.0-20170318121727-bc25dd6abe8e/go.mod h1:qZqlPyPvfsDJt+3wHJ1EvSXDuVjFTK0j2p/ca+gtsb8=
|
||||
github.com/dave/patsy v0.0.0-20210517141501-957256f50cba/go.mod h1:qfR88CgEGLoiqDaE+xxDCi5QA5v4vUoW0UCX2Nd5Tlc=
|
||||
github.com/dave/rebecca v0.9.1/go.mod h1:N6XYdMD/OKw3lkF3ywh8Z6wPGuwNFDNtWYEMFWEmXBA=
|
||||
github.com/dave/jennifer v1.7.0 h1:uRbSBH9UTS64yXbh4FrMHfgfY762RD+C7bUPKODpSJE=
|
||||
github.com/dave/jennifer v1.7.0/go.mod h1:nXbxhEmQfOZhWml3D1cDK5M1FLnMSozpbFN/m3RmGZc=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
|
||||
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/justincpresley/go-cobs v1.3.1 h1:PbQ6FqJ5GTIECZz+FwgDTJlHl2avdboWpGrjJG9Khjg=
|
||||
github.com/justincpresley/go-cobs v1.3.1/go.mod h1:L0d+EbGirv6IzsXNzwULduI2/z3ijkkAmsAuPMpLfqA=
|
||||
github.com/miekg/pkcs11 v1.0.3-0.20190429190417-a667d056470f/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
|
||||
|
@ -35,8 +28,8 @@ github.com/shamaton/msgpack/v2 v2.1.1 h1:gAMxOtVJz93R0EwewwUc8tx30n34aV6BzJuwHE8
|
|||
github.com/shamaton/msgpack/v2 v2.1.1/go.mod h1:aTUEmh31ziGX1Ml7wMPLVY0f4vT3CRsCvZRoSCs+VGg=
|
||||
github.com/shamaton/msgpackgen v0.3.0 h1:q6o7prOEJFdF9BAPgkOtfzJbs55pQi7g44RUnEVUxtM=
|
||||
github.com/shamaton/msgpackgen v0.3.0/go.mod h1:fd99fDDuxuTiWzkHC59uEGzrt/WDu+ltGZTbEWwVXIc=
|
||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
|
@ -48,35 +41,11 @@ github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 h1:UyzmZLoiDWMRywV4DUY
|
|||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
|
||||
github.com/thales-e-security/pool v0.0.2 h1:RAPs4q2EbWsTit6tpzuvTFlgFRJ3S8Evf5gtvVDbmPg=
|
||||
github.com/thales-e-security/pool v0.0.2/go.mod h1:qtpMm2+thHtqhLzTwgDBj/OuNnMpupY8mv0Phz0gjhU=
|
||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM=
|
||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2022 CAcert Inc.
|
||||
Copyright 2022-2023 CAcert Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -383,6 +383,18 @@ func (m *MsgPackHandler) handleSignCertificateCommand(
|
|||
signerRequest.SubjectDN.OrganizationalUnit = []string{command.OrganizationalUnit}
|
||||
}
|
||||
|
||||
if command.Locality != "" {
|
||||
signerRequest.SubjectDN.Locality = []string{command.Locality}
|
||||
}
|
||||
|
||||
if command.Province != "" {
|
||||
signerRequest.SubjectDN.Province = []string{command.Province}
|
||||
}
|
||||
|
||||
if command.Country != "" {
|
||||
signerRequest.SubjectDN.Country = []string{command.Country}
|
||||
}
|
||||
|
||||
x509Signing, err := m.x509SigningHandler.GetSigner(command.IssuerID, command.ProfileName)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get X.509 signing component: %w", err)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2021-2022 CAcert Inc.
|
||||
Copyright 2021-2023 CAcert Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -23,6 +23,6 @@ type RequestInformation struct{}
|
|||
|
||||
type SignedPublicKey struct{}
|
||||
|
||||
func (o *OpenPGPSigning) Sign(signingRequest *RequestInformation) (*SignedPublicKey, error) {
|
||||
func (o *OpenPGPSigning) Sign(_ *RequestInformation) (*SignedPublicKey, error) {
|
||||
return &SignedPublicKey{}, nil
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2021-2022 CAcert Inc.
|
||||
Copyright 2021-2023 CAcert Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -20,7 +20,6 @@ package openssl
|
|||
import (
|
||||
"bufio"
|
||||
"crypto/x509"
|
||||
"crypto/x509/pkix"
|
||||
"encoding/asn1"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -231,7 +230,7 @@ func (c CannotRevokeUnknown) Error() string {
|
|||
}
|
||||
|
||||
// StoreRevocation records information about a revoked certificate.
|
||||
func (r *Repository) StoreRevocation(revoked *pkix.RevokedCertificate) error {
|
||||
func (r *Repository) StoreRevocation(revoked *x509.RevocationListEntry) error {
|
||||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
|
||||
|
@ -307,7 +306,7 @@ func (r *Repository) StoreCertificate(signed *x509.Certificate) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *Repository) RevokedCertificates() ([]pkix.RevokedCertificate, error) {
|
||||
func (r *Repository) RevokedCertificates() ([]x509.RevocationListEntry, error) {
|
||||
var err error
|
||||
|
||||
r.lock.Lock()
|
||||
|
@ -318,14 +317,14 @@ func (r *Repository) RevokedCertificates() ([]pkix.RevokedCertificate, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
result := make([]pkix.RevokedCertificate, 0)
|
||||
result := make([]x509.RevocationListEntry, 0)
|
||||
|
||||
for _, entry := range r.entries {
|
||||
if entry.revokedAt != nil {
|
||||
result = append(result, pkix.RevokedCertificate{
|
||||
result = append(result, x509.RevocationListEntry{
|
||||
SerialNumber: entry.serialNumber,
|
||||
RevocationTime: *entry.revokedAt,
|
||||
Extensions: []pkix.Extension{entry.revocationReason.BuildExtension()},
|
||||
ReasonCode: int(entry.revocationReason),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2021-2022 CAcert Inc.
|
||||
Copyright 2021-2023 CAcert Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -48,10 +48,10 @@ func TestStoreRevocation(t *testing.T) {
|
|||
|
||||
notAfter := time.Now().UTC().Add(24 * time.Hour).UTC()
|
||||
|
||||
err = fr.StoreRevocation(&pkix.RevokedCertificate{
|
||||
err = fr.StoreRevocation(&x509.RevocationListEntry{
|
||||
SerialNumber: serial,
|
||||
RevocationTime: notAfter,
|
||||
Extensions: []pkix.Extension{revoking.CRLReasonKeyCompromise.BuildExtension()},
|
||||
ReasonCode: int(revoking.CRLReasonKeyCompromise),
|
||||
})
|
||||
|
||||
assert.ErrorIs(t, err, openssl.CannotRevokeUnknown{Serial: serial})
|
||||
|
@ -71,10 +71,10 @@ func TestStoreRevocation(t *testing.T) {
|
|||
), 0o600)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = fr.StoreRevocation(&pkix.RevokedCertificate{
|
||||
err = fr.StoreRevocation(&x509.RevocationListEntry{
|
||||
SerialNumber: serial,
|
||||
RevocationTime: time.Now(),
|
||||
Extensions: []pkix.Extension{revoking.CRLReasonKeyCompromise.BuildExtension()},
|
||||
ReasonCode: int(revoking.CRLReasonKeyCompromise),
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2021-2022 CAcert Inc.
|
||||
Copyright 2021-2023 CAcert Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -18,17 +18,17 @@ limitations under the License.
|
|||
package revoking
|
||||
|
||||
import (
|
||||
"crypto/x509/pkix"
|
||||
"crypto/x509"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// A Repository for storing certificate status information
|
||||
type Repository interface {
|
||||
// StoreRevocation stores information about a revoked certificate.
|
||||
StoreRevocation(*pkix.RevokedCertificate) error
|
||||
StoreRevocation(entry *x509.RevocationListEntry) error
|
||||
LoadCRL(*big.Int) ([]byte, error)
|
||||
StoreCRL(*big.Int, []byte) error
|
||||
RevokedCertificates() ([]pkix.RevokedCertificate, error)
|
||||
RevokedCertificates() ([]x509.RevocationListEntry, error)
|
||||
NextCRLNumber() (*big.Int, error)
|
||||
CleanUp()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2021-2022 CAcert Inc.
|
||||
Copyright 2021-2023 CAcert Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -117,11 +117,11 @@ type CRLInformation struct {
|
|||
NextUpdate time.Time
|
||||
}
|
||||
|
||||
func (r *X509Revoking) Revoke(revokeCertificate *RevokeCertificate) (*pkix.RevokedCertificate, error) {
|
||||
revoked := &pkix.RevokedCertificate{
|
||||
func (r *X509Revoking) Revoke(revokeCertificate *RevokeCertificate) (*x509.RevocationListEntry, error) {
|
||||
revoked := &x509.RevocationListEntry{
|
||||
SerialNumber: revokeCertificate.serialNumber,
|
||||
RevocationTime: time.Now(),
|
||||
Extensions: []pkix.Extension{revokeCertificate.reason.BuildExtension()},
|
||||
ReasonCode: int(revokeCertificate.reason),
|
||||
}
|
||||
|
||||
if err := r.repository.StoreRevocation(revoked); err != nil {
|
||||
|
@ -145,11 +145,11 @@ func (r *X509Revoking) createCRL() (*CRLInformation, error) {
|
|||
nextUpdate := time.Now().UTC().Add(defaultCRLValidity)
|
||||
|
||||
list, err := x509.CreateRevocationList(rand.Reader, &x509.RevocationList{
|
||||
SignatureAlgorithm: r.crlAlgorithm,
|
||||
RevokedCertificates: revoked,
|
||||
Number: nextNumber,
|
||||
ThisUpdate: time.Now().UTC(),
|
||||
NextUpdate: nextUpdate,
|
||||
SignatureAlgorithm: r.crlAlgorithm,
|
||||
RevokedCertificateEntries: revoked,
|
||||
Number: nextNumber,
|
||||
ThisUpdate: time.Now().UTC(),
|
||||
NextUpdate: nextUpdate,
|
||||
}, r.crlIssuer, r.signer)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not sign revocation list: %w", err)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2021-2022 CAcert Inc.
|
||||
Copyright 2021-2023 CAcert Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -53,7 +53,7 @@ type testRepo struct {
|
|||
crlNumber *big.Int
|
||||
crls map[string][]byte
|
||||
current string
|
||||
revoked []pkix.RevokedCertificate
|
||||
revoked []x509.RevocationListEntry
|
||||
}
|
||||
|
||||
func (t *testRepo) LoadCRL(b *big.Int) ([]byte, error) {
|
||||
|
@ -89,15 +89,15 @@ func (t *testRepo) NextCRLNumber() (*big.Int, error) {
|
|||
return t.crlNumber, nil
|
||||
}
|
||||
|
||||
func (t *testRepo) RevokedCertificates() ([]pkix.RevokedCertificate, error) {
|
||||
result := make([]pkix.RevokedCertificate, len(t.revoked))
|
||||
func (t *testRepo) RevokedCertificates() ([]x509.RevocationListEntry, error) {
|
||||
result := make([]x509.RevocationListEntry, len(t.revoked))
|
||||
|
||||
copy(result, t.revoked)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (t *testRepo) StoreRevocation(revoked *pkix.RevokedCertificate) error {
|
||||
func (t *testRepo) StoreRevocation(revoked *x509.RevocationListEntry) error {
|
||||
t.revoked = append(t.revoked, *revoked)
|
||||
|
||||
return nil
|
||||
|
@ -111,17 +111,17 @@ func (r *brokenRepo) NextCRLNumber() (*big.Int, error) {
|
|||
return nil, errors.New("don't know")
|
||||
}
|
||||
|
||||
func (r *brokenRepo) RevokedCertificates() ([]pkix.RevokedCertificate, error) {
|
||||
func (r *brokenRepo) RevokedCertificates() ([]x509.RevocationListEntry, error) {
|
||||
return nil, errors.New("no revocations for you")
|
||||
}
|
||||
|
||||
func (*brokenRepo) StoreRevocation(_ *pkix.RevokedCertificate) error {
|
||||
func (*brokenRepo) StoreRevocation(_ *x509.RevocationListEntry) error {
|
||||
return errors.New("cannot store")
|
||||
}
|
||||
|
||||
type noStoreRepo struct{}
|
||||
|
||||
func (r noStoreRepo) StoreRevocation(_ *pkix.RevokedCertificate) error {
|
||||
func (r noStoreRepo) StoreRevocation(_ *x509.RevocationListEntry) error {
|
||||
// do nothing
|
||||
return nil
|
||||
}
|
||||
|
@ -141,8 +141,8 @@ func (r noStoreRepo) StoreCRL(_ *big.Int, _ []byte) error {
|
|||
|
||||
func (r noStoreRepo) CleanUp() {}
|
||||
|
||||
func (b brokenRepoNoCrlNumber) RevokedCertificates() ([]pkix.RevokedCertificate, error) {
|
||||
return make([]pkix.RevokedCertificate, 0), nil
|
||||
func (b brokenRepoNoCrlNumber) RevokedCertificates() ([]x509.RevocationListEntry, error) {
|
||||
return make([]x509.RevocationListEntry, 0), nil
|
||||
}
|
||||
|
||||
func (b brokenRepoNoCrlNumber) NextCRLNumber() (*big.Int, error) {
|
||||
|
@ -153,7 +153,7 @@ type brokenRepoNoRevocations struct {
|
|||
noStoreRepo
|
||||
}
|
||||
|
||||
func (b brokenRepoNoRevocations) RevokedCertificates() ([]pkix.RevokedCertificate, error) {
|
||||
func (b brokenRepoNoRevocations) RevokedCertificates() ([]x509.RevocationListEntry, error) {
|
||||
return nil, errors.New("no revocations known")
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ func (b brokenRepoNoRevocations) NextCRLNumber() (*big.Int, error) {
|
|||
|
||||
func TestX509Revoking_Revoke(t *testing.T) {
|
||||
testRepository := testRepo{
|
||||
revoked: make([]pkix.RevokedCertificate, 0),
|
||||
revoked: make([]x509.RevocationListEntry, 0),
|
||||
crlNumber: big.NewInt(0),
|
||||
crls: map[string][]byte{},
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ func TestX509Revoking_Revoke(t *testing.T) {
|
|||
revoke, err := r.Revoke(revoking.NewRevokeCertificate(serial, revoking.CRLReasonKeyCompromise))
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, revoking.CRLReasonKeyCompromise.BuildExtension(), revoke.Extensions[0])
|
||||
assert.Equal(t, int(revoking.CRLReasonKeyCompromise), revoke.ReasonCode)
|
||||
assert.Equal(t, serial, revoke.SerialNumber)
|
||||
|
||||
var found bool
|
||||
|
@ -218,7 +218,7 @@ func TestX509Revoking_CreateCRL(t *testing.T) {
|
|||
logger.SetOutput(&bytes.Buffer{})
|
||||
|
||||
r := revoking.NewX509Revoking(
|
||||
&testRepo{revoked: make([]pkix.RevokedCertificate, 0), crlNumber: big.NewInt(0), crls: map[string][]byte{}},
|
||||
&testRepo{revoked: make([]x509.RevocationListEntry, 0), crlNumber: big.NewInt(0), crls: map[string][]byte{}},
|
||||
x509.SHA256WithRSA, certificate, key, logger,
|
||||
)
|
||||
|
||||
|
@ -241,11 +241,11 @@ func TestX509Revoking_CreateCRL(t *testing.T) {
|
|||
|
||||
var found bool
|
||||
|
||||
for _, item := range parsedCRL.RevokedCertificates {
|
||||
for _, item := range parsedCRL.RevokedCertificateEntries {
|
||||
if item.SerialNumber.Cmp(serial) == 0 {
|
||||
found = true
|
||||
|
||||
assert.Contains(t, item.Extensions, revoking.CRLReasonKeyCompromise.BuildExtension())
|
||||
assert.Equal(t, int(revoking.CRLReasonKeyCompromise), item.ReasonCode)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ func TestX509Revoking_GetCRL_WrongAlgorithm(t *testing.T) {
|
|||
logger.SetOutput(&bytes.Buffer{})
|
||||
|
||||
r := revoking.NewX509Revoking(
|
||||
&testRepo{revoked: make([]pkix.RevokedCertificate, 0), crlNumber: big.NewInt(0), crls: map[string][]byte{}},
|
||||
&testRepo{revoked: make([]x509.RevocationListEntry, 0), crlNumber: big.NewInt(0), crls: map[string][]byte{}},
|
||||
x509.ECDSAWithSHA256, certificate, key, logger,
|
||||
)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2022 CAcert Inc.
|
||||
Copyright 2022-2023 CAcert Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -225,7 +225,7 @@ func (r *FetchCRLResponse) String() string {
|
|||
revocationList.Issuer,
|
||||
revocationList.Number,
|
||||
revocationList.NextUpdate,
|
||||
len(revocationList.RevokedCertificates),
|
||||
len(revocationList.RevokedCertificateEntries),
|
||||
)
|
||||
_, _ = builder.WriteString(", CRL data:\n")
|
||||
_ = pem.Encode(builder, &pem.Block{
|
||||
|
@ -306,6 +306,9 @@ type SignCertificateCommand struct {
|
|||
CommonName string `msgpack:"cn"`
|
||||
Organization string `msgpack:"o"`
|
||||
OrganizationalUnit string `msgpack:"ou"`
|
||||
Locality string `msgpack:"locality"`
|
||||
Province string `msgpack:"province"`
|
||||
Country string `msgpack:"country"`
|
||||
Hostnames []string `msgpack:"hostnames"`
|
||||
EmailAddresses []string `msgpack:"email_addresses"`
|
||||
PreferredHash crypto.Hash `msgpack:"preferred_hash"`
|
||||
|
@ -326,6 +329,18 @@ func (c *SignCertificateCommand) String() string {
|
|||
_, _ = fmt.Fprintf(builder, ", ou=%s", c.OrganizationalUnit)
|
||||
}
|
||||
|
||||
if c.Locality != "" {
|
||||
_, _ = fmt.Fprintf(builder, "l=%s", c.Locality)
|
||||
}
|
||||
|
||||
if c.Province != "" {
|
||||
_, _ = fmt.Fprintf(builder, "st=%s", c.Province)
|
||||
}
|
||||
|
||||
if c.Country != "" {
|
||||
_, _ = fmt.Fprintf(builder, "st=%s", c.Country)
|
||||
}
|
||||
|
||||
if len(c.Hostnames) > 0 {
|
||||
builder.WriteString(", hostnames=[")
|
||||
|
||||
|
|
Loading…
Reference in a new issue