-
Notifications
You must be signed in to change notification settings - Fork 180
feat: X509.new now takes a keyword arguments #938
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
base: master
Are you sure you want to change the base?
Conversation
…opq to be set. It uses X509_new_ex() to create the X509 object, allowing a provider to be set. If the provider is not set, then a key residing in a provider (such as a tpm2) can not be used
Like I asked in your other PRs, please add a test case and adjust code formatting to match the existing style. We use 4 spaces per indentation level and put a space between This patch adds something ruby/openssl doesn't currently support, and I agree it could be useful. Adding as a keyword argument makes sense to me, too.
But I don't think it works as described. The "propq" string is used for "fetching algorithms", and within |
ID table[2]; | ||
table[0] = rb_intern("der"); | ||
table[1] = rb_intern("propq"); |
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.
X509.new(string, der: another_string)
is ambiguous and I don't think a keyword argument for the input is very useful. I'd prefer to allow just propq
this time.
Also, because we now use C99, we can simplify it:
ID table[] = { rb_intern("propq") };
|
||
#ifdef OSSL_USE_PROVIDER | ||
if(values[1] != Qundef) { | ||
propq = (char *)RSTRING_PTR(values[1]); |
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.
propq = (char *)RSTRING_PTR(values[1]); | |
propq = StringValueCStr(values[1]); |
We have to check that the argument is actually a String object and that the content is NUL-terminated.
First, it's a draft. I will fix the formatting. As to whether this is useful or required... I am arguing your point on the openssl-users list. I agree that (string, :der => string) is ambiguous. So one or other, do you think? |
We just have to ensure that the code paths in ruby/openssl are actually reached and that the propq string is correctly passed to OpenSSL. I think you may be able to use MD4 in the "legacy" provider, for example, and check that different propq strings show different behaviors.
I imagine it depends heavily on the particular provider and the use case. The propq on It would be very helpful if you could provide a working example code, whether in C or with some OpenSSL bindings.
The existing positional parameter doesn't have to be converted at the same time. Let's just support |
allowing the openssl propq to be set.
Unclear what else might be required going forward, which is why keyword arguments.
It uses X509_new_ex() to create the X509 object, allowing a provider to be set. If the provider is not set, then a key residing in a provider (such as a tpm2) can not be used
I am looking for review: I do not feel confident that I've handled all situations, but the unit tests do pass.