title: RCurl (or httr) - specifying cert info
body: <p>I've been playing with httr and RCurl for a while and am struggling with specifying some certificate information.</p>
  
  <p>I have a Curl CLI command that works just fine to log me in to a website that uses self-signed certs for authentication (as well as uname/pwd), it looks something like this...</p>
  
  <pre><code>curl -k -q -v --cert "../certs/foobar.pem" https://signon.foobar.com/certlogin -d "username=foo&amp;password=bar" -H "X-Application: Curltest"
  </code></pre>
  
  <p>This logs me in to foobar.com and returns a session token.</p>
  
  <p>The same command works if I use the corresponding .crt cert file and add a key using the --key option.</p>
  
  <p>I'm trying to do the same thing with RCurl or httr and keep getting an error that indicates that the cert is wrong. Bearing in mind that I know the cert is OK (as the CLI command works) I assume this is because I'm specifying the cert incorrectly in RCurl.</p>
  
  <p>So, quick question...</p>
  
  <p>How would you reproduce the CURL command given above in RCurl or httr?</p>
  
  <p>BTW this is on Ubuntu - so should not be related to the issues lots of folks are having with Mac OS X 10.9 +</p>
  
  <p>Many thanks</p>
  
  <p>Eluxoso
  (first time poster - be nice....!)</p>
  
  <p>Here is my (probably very inelegant &amp; certainly non-functioning) code</p>
  
  <p>RCurl:</p>
  
  <pre><code>Library(RCurl)
  url &lt;- "https://signon.foobar.com/certlogin"
  uname &lt;- "foo"
  pswd &lt;-"bar"
  headers &lt;- list("X-Application" = "Curltest")
  opts=curlOptions(verbose=TRUE, 
                   httpheader=headers, 
                   cainfo="../certs/foobar.pem", 
                   ssl.verifypeer=FALSE)
  postForm(url, 
           "username" = uname, "password"=pswd,
           .opts=opts,
           style='POST'
  )
  </code></pre>
  
  <p>httr:</p>
  
  <pre><code>library(httr)
  cafile="../certs/foobar.pem"
  resp&lt;-POST("https://signon.foobar.com/certlogin", 
             body = list(username="foo", password = "bar"),
             add_headers("X-Application" = "Curltest" ), 
             verbose(),
             encode = "form",
             config(cainfo = cafile, ssl.verifypeer=FALSE))
  content(resp,"text")
  </code></pre>
  
  <p>Having used a full pathname for the cert I still get the same server response, despite the CURL CLI command working.
  In the HTTP requests I noticed this:</p>
  
  <pre><code>SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
  </code></pre>
  
  <p>Is that relevant/helpful to someone?..</p>