-
Notifications
You must be signed in to change notification settings - Fork 51
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
base: master
Are you sure you want to change the base?
Feature/key info #38
Conversation
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.
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"); |
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.
println
pub fn key_usage(&self) -> Option<String> { | ||
unsafe { | ||
println!("Getting Key usage"); | ||
if (*self.0).pCertInfo.is_null() { |
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 think we need this check.
if keyUsageExtension.is_null() { | ||
return None; | ||
} else { | ||
let mut len = 500; |
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.
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); |
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.
key_usage_extension
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.