-
Notifications
You must be signed in to change notification settings - Fork 7
Migrate away from c-t-go/x509 and c-t-go/asn1 #198
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
Changes from all commits
ec09671
59fb25d
f88b170
0bd7127
48f2765
93ddf29
d39f05e
dbcaedd
dffb7a0
4a13f68
60433f4
ff44c33
cb16630
c97adc3
b181276
6c95c19
f142b99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ package scti | |
import ( | ||
"context" | ||
"crypto/sha256" | ||
"crypto/x509" | ||
"encoding/base64" | ||
"encoding/json" | ||
"errors" | ||
|
@@ -28,13 +29,11 @@ import ( | |
"sync" | ||
"time" | ||
|
||
"slices" | ||
|
||
"github.com/google/certificate-transparency-go/tls" | ||
"github.com/google/certificate-transparency-go/x509" | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
"github.com/transparency-dev/static-ct/internal/types" | ||
"github.com/transparency-dev/static-ct/internal/x509util" | ||
"github.com/transparency-dev/static-ct/modules/dedup" | ||
tessera "github.com/transparency-dev/trillian-tessera" | ||
"github.com/transparency-dev/trillian-tessera/ctonly" | ||
|
@@ -493,7 +492,7 @@ func entryFromChain(chain []*x509.Certificate, isPrecert bool, timestamp uint64) | |
|
||
// Next, post-process the DER-encoded TBSCertificate, to remove the CT poison | ||
// extension and possibly update the issuer field. | ||
defangedTBS, err := x509.BuildPrecertTBS(cert.RawTBSCertificate, preIssuer) | ||
defangedTBS, err := x509util.BuildPrecertTBS(cert.RawTBSCertificate, preIssuer) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to remove poison extension: %v", err) | ||
} | ||
|
@@ -510,7 +509,13 @@ func entryFromChain(chain []*x509.Certificate, isPrecert bool, timestamp uint64) | |
|
||
// isPreIssuer indicates whether a certificate is a pre-cert issuer with the specific | ||
// certificate transparency extended key usage. | ||
// copied form certificate-transparency-go/serialization.go | ||
func isPreIssuer(issuer *x509.Certificate) bool { | ||
return slices.Contains(issuer.ExtKeyUsage, x509.ExtKeyUsageCertificateTransparency) | ||
func isPreIssuer(cert *x509.Certificate) bool { | ||
// Look for the extension in the Extensions field and not ExtKeyUsage | ||
// since crypto/x509 does not recognize this extension as an ExtKeyUsage. | ||
for _, ext := range cert.Extensions { | ||
if types.OIDExtKeyUsageCertificateTransparency.Equal(ext.Id) { | ||
return true | ||
} | ||
} | ||
return false | ||
Comment on lines
+512
to
+520
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've seen this in a couple of places, feels like it might reasonably live exported in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - there's a TODO to merge them, I'll do this in a followup PR. This PR was 90% done before the other |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming idea for this fork package:
lax509
:)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sending a different PR to avoid making this one even larger.