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

ssl: add ssl_cert option to support pkcs12 self-signed cert #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lenage
Copy link

@lenage lenage commented Mar 18, 2018

Added ssl_cert, ssl_cert_type and ssl_key_password to support self-signed PKCS12 cert.

see cURL docs for those options:

https://curl.haxx.se/libcurl/c/CURLOPT_SSLCERT.html
https://curl.haxx.se/libcurl/c/CURLOPT_SSLCERTTYPE.html

I just wrote one spec, and it passed, if i missed something, please let me know.


ssl_key_password = rb_funcall(request, rb_intern("ssl_key_password"), 0);
if(RTEST(ssl_key_password)) {
curl_easy_setopt(curl, CURLOPT_SSLKEYPASSWD, StringValuePtr(ssl_key_password));
Copy link
Author

Choose a reason for hiding this comment

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

https://curl.haxx.se/mail/lib-2005-03/0172.html

found CURLOPT_SSLKEYPASSWD in maillist

Copy link
Collaborator

@julik julik left a comment

Choose a reason for hiding this comment

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

Looks really impressive, thanks! Good to merge but I am curious what the failure mode is with a non-happy path. Is there a clear exception message propagated via the curl abort?

@session.insecure = nil
@session.ssl_cert = 'spec/certs/keystore.p12'
@sessions.ssl_cert_type = "p12"
@session.ssl_key_password = "pkcs12"
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the password is set incorrectly, what is the exception that is going to be raised? Do we need a separate exception type for this?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, will add a spec for that case

Copy link
Author

Choose a reason for hiding this comment

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

curl -v --cert ./keystore.p12 --pass pkcs13 https://google.com                                                                                                                                           * Rebuilt URL to: https://google.com/
*   Trying 74.125.68.113...
* TCP_NODELAY set
* Connected to google.com (74.125.68.113) port 443 (#0)
* WARNING: SSL: Certificate type not set, assuming PKCS#12 format.
* SSL: Incorrect password for the certificate "./keystore.p12" and its private key.
* Closing connection 0

trying to connect with wrong password, seems like failed at SSL level

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, would be useful to check for a proper exception in that case on the Patron end

Copy link
Author

Choose a reason for hiding this comment

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

sorry, it's kind of busy in those days, i will catch and update this PR asap

it "should work when ssl_cert is supplied" do
@session.insecure = nil
@session.ssl_cert = 'spec/certs/keystore.p12'
@sessions.ssl_cert_type = "p12"
Copy link
Collaborator

Choose a reason for hiding this comment

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

@sessions should probably be @session? And if it isn't does this test pass?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, my bad

@julik
Copy link
Collaborator

julik commented May 10, 2018

@lenage Sorry it's been a while - but could you maybe take another look at the feedback?

@joshgoebel
Copy link

Is this project pretty much unmaintained now?

@julik
Copy link
Collaborator

julik commented Oct 14, 2024

I'm looking at PRs regularly here. On this PR there was feedback which was left unadressed. Also I do think that using a self-signed cert does merit setting up the test Puma with that cert to verify whether connecting works correctly and it is possible to do a GET.

@joshgoebel
Copy link

I was also looking at the fact that there hasn't been a release since 2014.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants