Skip to content
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

Check for empty cert chain #163

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions go/util/tls/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type InvalidReason int

const (
EmptyPeerCertificate InvalidReason = iota
NoPeerCertificates
TooManyPeerCertificates
InvalidCN
InvalidSN
Expand Down Expand Up @@ -54,6 +55,10 @@ func (e CertificateInvalidError) Error() string {
}

func ValidatePeerCertificates(ctx context.Context, cquery ctypes.QueryClient, certs []*x509.Certificate, usage []x509.ExtKeyUsage) (sdk.Address, *x509.Certificate, error) {
if len(certs) == 0 {
return nil, nil, CertificateInvalidError{nil, NoPeerCertificates}
}

if len(certs) != 1 {
return nil, nil, CertificateInvalidError{nil, TooManyPeerCertificates}
}
Expand Down
Loading