Skip to content

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

Merged
merged 3 commits into from
Feb 25, 2021

Conversation

omorsi
Copy link
Contributor

@omorsi omorsi commented Feb 24, 2021

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.

e7, err := pkcs7.Encrypt(deg, msg.p7.Certificates)

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.

@omorsi
Copy link
Contributor Author

omorsi commented Feb 24, 2021

@pavolmarko FYI!

Copy link
Member

@groob groob left a 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.

shouldCreateCSR bool
}

var testNewCSRRequestData = []testNewCSRRequestStruct{
Copy link
Member

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

Copy link
Contributor Author

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 :-)


// 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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// TODO (issue/#) here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@omorsi omorsi requested a review from groob February 25, 2021 15:09
@groob groob merged commit b29dc20 into micromdm:master Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants