title: How to Use RCurl or RMongo via HTTP with Authentication and Self Signed SSL to Read in JSON Data
body: <p>I am using R to write a program and perform some analyses. The data is being captured by an outside vendor with MongoDB in JSON format. They are providing it to me via a URI on port 443, which they want me to query using cURL. They have authentication in place and self signed SSL. </p>
  
  <p>I can authenticate and dump the data via curl in Windows, however to create a long term sustainable solution it needs to all be done within R. </p>
  
  <p>The vendor says that RCurl "should" work but they aren't providing any support and they basically just don't like the idea of using RMongo and have no comment on it (but if we could make it work that would be awesome, in my opinion).</p>
  
  <p>I have the following packages loaded
  - ggplot2
  - DBI
  - rjson
  - RJSONIO (I sometimes don't load this one if I'm using rjson, or visa versa)
  - RMongo
  - rstudio
  - RCurl</p>
  
  <p>The self signed certificate caused issues even with curl, but those were resolved by editing settings in Ruby and then launching a cmd shell with Ruby and using curl that way. I'm not sure if the problems in R are related.</p>
  
  <p>When trying to go the RCurl route I end up with commands/errors like this:</p>
  
  <pre><code>  x &lt;- getURL("https://xxx.xx.xxx.xxx:443/db/_authenticate", userpwd="xxxx:xxxxx") }{Error in function (type, msg, asError = TRUE)  : couldn't connect to host
  </code></pre>
  
  <p>and when trying to use RMongo I'm even more clueless...</p>
  
  <pre><code>&gt; mongo &lt;- mongoDbConnect("xxx.xx.xxx.xxx")
  </code></pre>
  
  <blockquote>
    <p>username = "xxxx"
    password="xxxxxxxxxxxxx"
    authenticated &lt;- dbAuthenticate(mongo, username, password)
    Feb 25, 2013 4:00:09 PM com.mongodb.DBTCPConnector fetchMaxBsonObjectSize
    WARNING: Exception determining maxBSON size using0
    java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused: connect
        at com.mongodb.DBPort.<em>open(DBPort.java:224)
        at com.mongodb.DBPort.go(DBPort.java:101)
        at com.mongodb.DBPort.go(DBPort.java:82)
        at com.mongodb.DBPort.findOne(DBPort.java:142)
        at com.mongodb.DBPort.runCommand(DBPort.java:151)
        at com.mongodb.DBTCPConnector.fetchMaxBsonObjectSize(DBTCPConnector.java:429)
        at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:416)
        at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:193)
        at com.mongodb.DBApiLayer$MyCollection.</em>_find(DBApiLayer.java:303)
        at com.mongodb.DB.command(DB.java:159)
        at com.mongodb.DB.command(DB.java:144)
        at com.mongodb.DB._doauth(DB.java:503)
        at com.mongodb.DB.authenticate(DB.java:440)
        at rmongo.RMongo.dbAuthenticate(RMongo.scala:24)</p>
  </blockquote>
  
  <pre><code>Error in .jcall(rmongo.object@javaMongo, "Z", "dbAuthenticate", username,  : 
  com.mongodb.MongoException$Network: can't call something
  Feb 25, 2013 4:00:10 PM com.mongodb.DBPortPool gotError
  WARNING: emptying DBPortPool to 127.0.0.1:27017 b/c of error
  java.io.IOException: couldn't connect to [/127.0.0.1:27017]     bc:java.net.ConnectException: Connection refused: connect
  at com.mongodb.DBPort._open(DBPort.java:224)
  at com.mongodb.DBPort.go(DBPort.java:101)
  at com.mongodb.DBPort.go(DBPort.java:82)
  at com.mongodb.DBPort.call(DBPort.java:72)
  at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:202)
  at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:303)
  at com.mongodb.DB.command(DB.java:159)
  at com.mongodb.DB.command(DB.java:144)
  at com.mongodb.DB._doauth(DB.java:503)
  at com.mongodb.DB.authenticate(DB.java:440)
  at rmongo.RMongo.dbAuthenticate(RMongo.scala:24)
  </code></pre>
  
  <p>any help would be greatly appreciated!</p>