HttpsUrlConnection and keep-alive

I ran into this exact same problem and finally have a solution after some in-depth debugging. Http(s)UrlConnection does handle Keep-Alive by default but sockets must be in a very specific condition in order to be reused. These are: Input streams must be fully consumed. You must call read on the input stream until it returns … Read more

Arduino Due HTTPS Support

Unfortunately this is too long for a comment. ► No out of the box solution From what I have gathered, there is no straightforward solution for a webserver running on the Atmel SAM3X8E ARM Cortex-M3 CPU that outputs HTTPS out of the box. Texas Intstruments provides better options at the moment using their boards equipped … Read more

Apache warns that my self-signed certificate is a CA certificate

Short way (e.g. with OpenSSL 1.1.0f and Apache 2.4.37): openssl genrsa -out notEncodedPk.key 3072 openssl req -new -out website.csr -sha256 -key notEncodedPk.key openssl x509 -req -in website.csr -days 365 -signkey notEncodedPk.key -out website.cert -outform PEM genrsa generates a 3072 bit RSA-Key. (The system should be online for some time to have good data in /dev/(u)random … Read more

Redirect HTTP to HTTPS:PORT in Tomcat

You can do it to every app deployed to tomcat by adding this to the end of tomcat_dir/conf/web.xml: <security-constraint> <web-resource-collection> <web-resource-name>Entire Application</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <!– auth-constraint goes here if you requre authentication –> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> So you don’t have to change it on the web.xml of your webapp. That should work, assuming you … Read more

Using java class HttpsURLConnection

Just keep it java.net.URLConnection or cast it to java.net.HttpURLConnection instead. Both offers methods to do the desired task as good. A side remark unrelated to the technical problem: you should never explicitly import/use Sun Java SE implementation specific classes in your code. Those are undocumented classes and are subject to changes which may cause your … Read more

Force SSL/HTTPS with mod_rewrite [duplicate]

The following solution works for both proxied and unproxied servers. So if you are using CloudFlare, AWS Elastic Load Balancing, Heroku, OpenShift or any other Cloud/PaaS solution and you are experiencing redirect loops with normal HTTPS redirects, give it a try. RewriteEngine On # If we receive a forwarded http request from a proxy… RewriteCond … Read more

How do I fix “ssl handshake failed” with ApacheBench?

ApacheBench doesn’t seem to be capable of ignoring certificate problems (at least some of them) so I wrote this script: #!/bin/bash K=200; HTTPSA=’https://192.168.1.103:443/’ date +%M-%S-%N>wgetres.txt for (( c=1; c<=$K; c++ )) do wget –no-check-certificate –secure-protocol=SSLv3 –spider $HTTPSA done date +%M-%S-%N>>wgetres.txt It’s not as precise as AB, but gives the idea. Does well in comparison tests.