federicotdn / verb

Organize and send HTTP requests from Emacs
https://melpa.org/#/verb
GNU General Public License v3.0
545 stars 20 forks source link

https requests with certificates? #29

Closed matteoredaelli closed 3 years ago

matteoredaelli commented 4 years ago

I need to do get/post requets to a https site using certificates. I can do it with curl, I'd like to do using this nice package...

federicotdn commented 4 years ago

Hi @matteoredaelli. How do you accomplish this using curl? Could you provide an example? I want to be sure I understand what the feature is.

matteoredaelli commented 4 years ago

A sample command is

curl --cert certificates/prd/client.pem --insecure --key certificates/prd/client_key.pem https://localhost:4242/qrs/dataconnection/full?xrfkey=0123456789abcdef --header "x-qlik-xrfkey: 0123456789abcdef" --header "X-Qlik-User: UserDirectory=internal;UserId=sa_repository" -H "Content-Type: application/json"

I asked the same question elsewhere (issues in request.el project) and they suggested

(let ((request-curl-options (split-string "--key ./admin-key.pem --cert ./admin.pem"))
      (request-backend 'curl))
  (request
 "http://XXXXX/get"
 ...
federicotdn commented 4 years ago

Hmm, I think this could be accomplished via some auth-source configuration. See here: https://www.gnu.org/software/emacs/manual/html_mono/auth.html#Help-for-users.

Assuming that your auth-sources variable contains "~/.authinfo", maybe you could try placing the following contents in your ~/.authinfo file:

machine localhost port 4242 key certificates/prd/client_key.pem cert certificates/prd/client.pem

(note that you might need to make those two paths absolute instead of relative)

Then you should also set network-stream-use-client-certificates to t and possibly restart Emacs.

federicotdn commented 3 years ago

@matteoredaelli did that work for you? If it did, we can close this issue.

matteoredaelli commented 3 years ago

ok thanks