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

Feature/key info #38

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

sstecko
Copy link
Contributor

@sstecko sstecko commented Aug 17, 2017

This function adds the ability to gather the Key Usage info in string format from a cert context.

This can be used to filter certs provided to a Tls_Stream in the security context such that non-signature keys are not supplied. I have been experiencing issues where the server requests client certificate validation but the client supplies symmetric (S/MIME) keys, causing the request to crash server-side.

Copy link
Collaborator

@sfackler sfackler left a comment

Choose a reason for hiding this comment

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

Can you add a test as well?

/// Returns a string that describes the intended key usages of the certificate.
pub fn key_usage(&self) -> Option<String> {
unsafe {
println!("Getting Key usage");
Copy link
Collaborator

Choose a reason for hiding this comment

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

println

pub fn key_usage(&self) -> Option<String> {
unsafe {
println!("Getting Key usage");
if (*self.0).pCertInfo.is_null() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need this check.

if keyUsageExtension.is_null() {
return None;
} else {
let mut len = 500;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why 500?

if (*self.0).pCertInfo.is_null() {
return None;
}
let mut keyUsageExtension = crypt32::CertFindExtension(szOID_KEY_USAGE.as_ptr() as winapi::LPSTR, (*(*self.0).pCertInfo).cExtension, (*(*self.0).pCertInfo).rgExtension);
Copy link
Collaborator

Choose a reason for hiding this comment

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

key_usage_extension

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