WS on HTTP vs WSS on HTTPS

“wss works on both http and https” ??? This is a strange phrase. wss is secure only because it means “WebSocket protocol over https“. WebSocket protocol itself is not secure. There is no Secure WebSocket protocol, but there are just “WebSocket protocol over http” and “WebSocket protocol over https”. See also this answer. As the … Read more

How to force SSL / https in Express.js

Just in case you’re hosting on Heroku and just want to redirect to HTTPS regardless of port, here’s the middleware solution we’re using. It doesn’t bother to redirect if you’re developing locally. function requireHTTPS(req, res, next) { // The ‘x-forwarded-proto’ check is for Heroku if (!req.secure && req.get(‘x-forwarded-proto’) !== ‘https’ && process.env.NODE_ENV !== “development”) { … Read more

Can’t connect to HTTPS site using cURL. Returns 0 length content instead. What can I do?

I had the same problem today. Curl comes with an outdated file to authenticate HTTPS certificates from. get the new one from: http://curl.haxx.se/ca/cacert.pem save it into some dir on your site and add curl_setopt ($curl_ch, CURLOPT_CAINFO, dirname(__FILE__).”/cacert.pem”); To every request 🙂 IGNORE any dumbass comments about disabling CURLOPT_VERIFYPEER and CURLOPT_VERIFYHOST!! That leaves your code vulnerable … Read more

Disable certificate verification in PHP SoapClient

SoapClient takes a stream context in its parameters, which you can create yourself. That way you can control almost every aspect of the transport layer: $context = stream_context_create([ ‘ssl’ => [ // set some SSL/TLS specific options ‘verify_peer’ => false, ‘verify_peer_name’ => false, ‘allow_self_signed’ => true ] ]); $client = new SoapClient(null, [ ‘location’ => … Read more

Allowing Java to use an untrusted certificate for SSL/HTTPS connection

Here is some relevant code: // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new TrustManager[]{ new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType) { } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType) { } } }; // Install the all-trusting … Read more