-
Notifications
You must be signed in to change notification settings - Fork 988
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
enforce certificate correctness in TBSCertificate.SignWith #1266
base: cert-v2
Are you sure you want to change the base?
Conversation
if n.Addr().Zone() != "" { | ||
return fmt.Errorf("unsafe_networks may not contain zones: %s", n) | ||
} | ||
//todo are unsafe networks that overlap networks allowed? |
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.
Yes, you might have 10.0.0.0/8
point to one host but 10.0.0.0/16
to another, it makes less sense to have overlapping in a CA certificate but that's also fine.
@@ -76,15 +76,89 @@ func (t *TBSCertificate) Sign(signer Certificate, curve Curve, key []byte) (Cert | |||
} | |||
} | |||
|
|||
// readyToSign checks all signing requirements that don't require us to cross-reference with a CA | |||
func (t *TBSCertificate) readyToSign() error { |
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.
I had started on this validation in cert_v1.go
and cert_v2.go
specifically that way we don't accidentally leak rules from one version to the other that shouldn't apply. We also need to do these things at unmarshal (or at a minimum at handshake and cert loading time) to ensure we are working with a valid certificate.
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.
ah yeah nice catch, I'll move this
if t.Version == Version1 { | ||
return fmt.Errorf("certificate v1 may not contain IPv6 unsafe networks: %v", t.Networks) | ||
} | ||
if !hasV6Networks && !t.IsCA { |
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.
I don't disagree but I am curious if this will haunt us in the future
return fmt.Errorf("IPv6 unsafe networks require an IPv6 address assignment") | ||
} | ||
} else if n.Addr().Is4() { | ||
if !hasV4Networks && !t.IsCA { |
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.
I don't disagree but I am curious if this will haunt us in the future
No description provided.