-
Notifications
You must be signed in to change notification settings - Fork 136
Encode CSRs only with certificates with KeyEncipherment KeyUsage #136
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
Conversation
@pavolmarko FYI! |
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.
A few nits & gofmt. Otherwise it looks good to me.
scep/scep_test.go
Outdated
shouldCreateCSR bool | ||
} | ||
|
||
var testNewCSRRequestData = []testNewCSRRequestStruct{ |
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'd move both the struct and variable inside the function and refactor the for loop to use t.Run.
Example here (t.Parallel optional): https://github.com/golang/go/wiki/TableDrivenTests#parallel-testing
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.
Thanks for letting me know about that. That's way cleaner :-)
scep/scep_test.go
Outdated
|
||
// GenerateSubjectKeyID generates SubjectKeyId used in Certificate | ||
// ID is 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey | ||
func generateSubjectKeyID(pub crypto.PublicKey) ([]byte, 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.
// TODO (issue/#) here
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.
Done.
This PR is to solve issue #123.
Copying the issue description here to save readers' time.
Currently, the CSR sent in a PKCSReq message is encrypted with all the certificates returned from GetCaCert operation.
scep/scep/scep.go
Line 448 in f3adbb7
A windows SCEP server may not just return the CA certificate, but also NDES certificates. Some of these certificates are not created with KeyEncipherment KeyUsage. Some of them are only for Digital Signature purposes. Adding these certificates as recipients for the encrypted messages introduces decryption errors from the server's side.
The proposal here is to filter the certificates received from GetCaCert by KeyUsage, particularly KeyEncipherment, and use only those as the encrypted content recipients.