Gheek.net

July 22, 2011

How to use curl to access a HTTPS URL using a Client Certificate

Filed under: Apache, linux, nix, shell scripts, tomcat — lancevermilion @ 11:14 am

I needed to check a HTTPS URL that required authentication of a client Certificate from the command line.

Using curl was a perfect fit.

curl --insecure --cert-type pem --cert /home/dummyuser/client-cert-stacked.pem --interface eth0:1 "https://192.168.1.2/GetKeepAlive"

Note: I use double quotes " " around the url because if there are any special characters or spaces it will not be read correctly.

Options Option Description
--insecure or -k Disable Certificate Verification against a Root/Intermediate
--cert or -E (HTTPS) Tells curl to use the specified certificate file. The certificate must be in PEM format.

If the optional password isn’t specified, it will be queried for on the terminal. Note that this certificate is the
private key and the private certificate concatenated!

If this option is used several times, the last one will be used.

--cert-type (SSL) Private key file type (DER, PEM, and ENG are supported).
--interface Query the URL using a specified interface.
Advertisements

January 25, 2008

HTTP redirect to HTTPS

Filed under: Apache — Tags: , , , , — lancevermilion @ 4:19 pm


#########################################
#### XXX: BEGIN EDIT FOR MOD_REWRITE ####
#### This is intended to force HTTPS ####
#### for all inbound HTTP requests ####

####
# This module (mod_rewrite) simply tells Apache2 that all connections to
# port 80 need to go to port 443 - SSL - No exceptions
####

LoadModule rewrite_module modules/mod_rewrite.so

RewriteEngine on

####
# The line below sets the rewrite condition for mod_rewrite.so.
# That is, if the server port does not equal 443, then this condition is true
####

ReWriteCond %{SERVER_PORT} !^443$

####
# The line below is the rule, it states that if above condition is true,
# and the request can be any url, then redirect everything to https:// plus
# the original url that was requested.
####

RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]

#### XXX: END EDIT FOR MOD_REWRITE ####
#######################################

Create a free website or blog at WordPress.com.