SlimerJS ignore SSL errors
Asked Answered
B

1

5

I'm pretty far down the path of incorporating SlimerJS into my web scrapers and I've come across an issue. One site I am working on just had their SSL certificate go invalid. Upon looking at Slimer's SSL documentation, it appears that they do not support PhantomJS's ignore-ssl-errors option. Is there a way around this? The SSL certificate error page that appears in the browser does not have any sort of continue button that I can make Slimer click. As an FYI, I am using CasperJS as a wrapper for SlimerJS.

Bunn answered 17/12, 2013 at 2:48 Comment(0)
M
8

My blog entry (pasted in below) explains how (and it shows the Casper instructions too):


SlimerJS (as of 0.8.3) lacks the commandline options of PhantomJS to say "relax about bad certificates". Unfortunately the self-signed SSL certificate, that developers typically use during development, counts as a bad certificate.

Here are the steps needed to handle this:

  1. slimerjs --createprofile AllowSSL Make a note of the directory it has created. (You can call your new profile anything, "AllowSSL" is just for example.)

  2. Go to normal desktop Firefox, browse to the URL in question, see the complaint, add it as a security exception. Chances are, if you have been testing your website already, that you've already done this and you can skip this step.

  3. Go to your Firefox profile, and look for the file called "cert_override.txt". Copy that to the directory you created in step 1.

  4. Have a look at the copy you just made of "cert_override.txt". If it only has the entry you added in step 2, you are done. Otherwise, remove the entries you don't want. (The file format is easy: one certificate per line.)

  5. Now when you need to run slimerjs you must run it with the "-P AllowSSL" commandline parameter. E.g. slimerjs -P AllowSSL httpstest.js

    If you are using SlimerJS with CasperJS (requires CasperJS 1.1 or later), do the same, e.g.

    casperjs test --engine=slimerjs -P AllowSSL tests_involving_https.js
    

Troubleshooting Ideas

Use export SLIMERJSLAUNCHER=/usr/bin/firefox to have SlimerJS use your local copy of Firefox, rather than its internal Gecko engine. This should definitely work, because in step 2 above you added the security exception to that version of Firefox. (The rest of the instructions above are just for getting it to work with the internal Gecko engine that comes with SlimerJS.)

Monoplegia answered 17/12, 2013 at 5:19 Comment(5)
I +1'ed this because I really feel like it is the right answer, however I couldn't get it to work. I copied the cert_override file and even tried using casperjs -profile /path/to/mozilla/profile and both times received the same SSL error. Let me know if you would be able to help me debug this and what information you would need.Bunn
@SamSullivan You should never need to give the profile directory to casper or slimer, because slimerJS chose the directory (that is step 1).Monoplegia
I had tried both the profile directory and profile (I eventually will need the profile directory so I can keep the profile in my Git repo). I tried your troubleshooting, and it seemed to work but caused some more errors since my local dev machine is using an unsupported Firefox. I tried recreating the cert_override.txt on this machine (not my Windows machine) and it worked fine this time..thank you for all of your help!Bunn
1. I've been racking my brain on this, this morning. One step I've made in the right direction is that these profiles are stored in $HOME/.innophi/slimerjs/Vociferance
2. Then I found the cert_override.txt file for firefox in ~/.mozilla/firefox/xxxx.default folder and copied it to the "xxxxx.AllowSSL" folder in the $HOME/.innophi/slimerjs/ folderVociferance

© 2022 - 2024 — McMap. All rights reserved.