User Tools

Site Tools

This wiki is read only and for archival purposes only. >>>>>>>>>> Please use the new OpenWrt wiki at <<<<<<<<<<


This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:howto:wget-ssl-certs [2012/12/03 21:04]
avalon a little IMO useful information
doc:howto:wget-ssl-certs [2015/10/31 10:31] (current)
Cor moved simple instructions to TOP, to save people HOURS of messing around doing what can be done in one simple command. Sheesh!
Line 1: Line 1:
 +===== SSL and Certificates in wget =====
 +This is a short tutorial on how to make wget (with libSSL) accept trusted certificate authorities. Without trusted certificate authorities,​ any party can pretend to be the site wget tries to contact. In addition to proving the server on the other end is who it says it is, using SSL means encryption will protect the request while in transit, e.g. a DDNS password.
 +//Note: This probably won't work for wget(matrixtunnel) and it can't work for wget(nossl) because wget looks for the certificates in a libSSL dependand way. Please add information for other flavors of wget.//
 +==== A Caveat ====
 +With the release of wget 1.13 in August 2011 this section is most probably outdated.
 +There is a known bug ([[http://​​cgi-bin/​bugreport.cgi?​bug=409938|here]],​ [[https://​​bugs/?​20421|here]],​ [[https://​​bugs/?​23934|and here]]) in wget 1.12 which prevents successful SSL connections to many sites. is one such site, wget reports:
 +''​ERROR:​ certificate common name `*'​ doesn'​t match requested host name `'​.
 +To connect to insecurely, use `--no-check-certificate'​.''​
 +<​del>​The bug has been fixed, but wget hasn't had a release since 22-Sep-2009. As of 16-Mar-2011,​ [[http://​​archive/​html/​bug-wget/​2011-03/​msg00015.html|it looks like]] a new version of wget will be released "​soon",​ which will contain this patch.</​del> ​ wget (1.13.4-1) is now available in the OpenWRT repositories.
 +====Install wget (with SSL)====
 +The default wget in OpenWRT is provided by Busybox, which does not support SSL. If you want to use SSL (https) URLs, you can install the real wget:
 +opkg update
 +opkg install wget
 +/​usr/​bin/​wget points now to the full version.
 +====Certificate Directory====
 +  - Create the wget/libSSL certificate directory: <code bash>​mkdir -p /​etc/​ssl/​certs</​code>​
 +  - So wget knows where to look, update ''/​etc/​profile''​ and add the line: <code bash>​export SSL_CERT_DIR=/​etc/​ssl/​certs</​code>​
 +  - Update shell: <code bash>​source /​etc/​profile</​code>​
 +  - you can also use ''/​etc/​ssl/​certs''​ directory with ''​curl --capath''​
 +Note: if you need SSL in your DDNS client, look also here [[ddns.client#​using.wget]]
 +==== Adding root certificates ====
 +Most browsers/​distributions/​etc ship with root certificates from the major Certificate Authorities,​ such as VeriSign and GeoTrust. Root certificates are used to validate the certificates presented by servers. OpenWRT does not include root certificates,​ so it is up to you to install them.
 +===Adding certificates through opkg===
 +You can use opkg to install the certificates from the major CA
 +<​code>​opkg install ca-certificates</​code>​
 +Now you have the major root certificates installed in /​etc/​ssl/​certs
 +===Adding certificates manually===
 +Let say we want to install the root certificate authority for The domain https://​ is signed by the <​del>​[[http://​​resources/​root_certificates/​certificates/​Equifax_Secure_Certificate_Authority.cer | "​Equifax"​ root certificate]]</​del>​. We need to download the root certificate,​ then place it in the certificate directory. Certificates in /​etc/​ssl/​certs must be named after their hash value so that they can be found.
 +It is easier to find the root certificate with any modern web browser (e.g. firefox) by opening the site with https, viewing the certificate and exporting it from the browser to a pem or base64 cer file.  Using openssl s_client allows for easy downloading of the remote server'​s SSL certificate chain. ​ You should verify the chain you get with another source such as your web browser.
 +The first step is installing ''​openssl-util'':<​code>​opkg install openssl-util</​code>​
 +Now you can use either the manual method or the script below to install certs into /​etc/​ssl/​certs. Make sure to use openssl from the OpenWrt device because if you try this from your linux PC, you may get a completely different hash for the same exact certificate due to a difference in the version of openssl.
 +^ shell prompt ^
 +|<code bash>
 +cd /​etc/​ssl/​certs
 +openssl s_client -connect​443 < /dev/null > temporary.out
 +openssl x509 -outform PEM < temporary.out >
 +##### create link using the hash value from openssl #####
 +# store certificate hash value in HASH append .0
 +HASH=`openssl x509 -hash -noout -in`.0
 +# create link
 +ln -s $HASH
 +//Note: If another cert has the same hash use suffix ''​.1''​ or ''​.2''​ instead of ''​.0''​. To see the hash value type ''​echo $HASH''​.//​
 +===Adding certificates with
 +Place this script in a file named,​ using an editor like vi or nano (if installed). ``chmod +x`` to mark it executable, then use it like this: <​code>​wget​certificate.cer
 +./​ certificate.cer</​code>​
 +^ ^
 +|<code bash>
 +# author: joda
 +if [ ! -f $openssl ]; then
 +  echo "​ERROR:​ Can't find $openssl. openssl-util installed?"​ >&2
 +if [[ "​$1"​ = "​-f"​ ]]; then
 +   ​overwrite=1
 +   shift # remove $1
 +if [ -f "​$1"​ ]; then
 +  certfile=$1
 +  certname=`basename $certfile`
 +  echo "​Certificate $certname"​
 +  echo " ​ copy to $certdir"​
 +  if [ "​1"​ -ne "​$overwrite"​ ] && [ -f "​$certdir/​$certname"​ ]; then
 +    echo >&2
 +    echo "​ERROR:​ certificate $certname exists"​ >&2
 +    exit 2;
 +  fi
 +  cp "​$1"​ "​$certdir/​$certname"​
 +  # create symbolic link from hash
 +  echo -n " ​ generating hash: "
 +  HASH=`$openssl x509 -hash -noout -in $certfile`
 +  echo "​$HASH"​
 +  # handle hash collisions
 +  suffix=0
 +  while [ "​1"​ -ne "​$overwrite"​ ] && [ -h "​$certdir/​$HASH.$suffix"​ ]; do
 +    let "​suffix += 1"
 +  done
 +  echo " ​ linking $HASH.$suffix -> $certname"​
 +  if [ $overwrite ]; then
 +    ln -sf "​$certname"​ "​$certdir/​$HASH.$suffix"​
 +  else
 +    ln -s "​$certname"​ "​$certdir/​$HASH.$suffix"​
 +  fi
 +  echo >&2
 +  echo "​ERROR:​ file does not exist $1" >&2
 +  echo >&2
 +  echo "This script adds (root) certificates for wget(ssl) to $certdir."​ >&2
 +  echo "​SYNTAX:​ `basename $0` [Options] [x509-certificate]"​ >&2
 +  echo >&2
 +  echo "​Option:​ -f      force overwriting if certificate exists"​ >&2
 +===== Trouble Shooting =====
 +==== Backfire 10.3 Conflict: /​usr/​bin/​wget -> /​bin/​busybox blocks wget ====
 +Solution: Move old wget until new wget is installed ("opkg install"​ needs wget)
 +Using SSH/Telnet shell: ​
 +^shell prompt^
 +|<code bash>ln -sf /​bin/​busybox /bin/wget
 +rm /​usr/​bin/​wget
 +opkg install wget
 +rm /​bin/​wget</​code>​|
 + --- //[[joda]] 2010/06/19 20:57//
 +==== Confirm wget SSL root ====
 +Example: ​ wget https://​​