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.
With the release of wget 1.13 in August 2011 this section is most probably outdated.
There is a known bug (here, here, and here) in wget 1.12 which prevents successful SSL connections to many sites. Dyndns.com is one such site, wget reports:
ERROR: certificate common name `*.dyndns.com' doesn't match requested host name `dyndns.com'.
To connect to dyndns.com insecurely, use `–no-check-certificate'.
The bug has been fixed, but wget hasn't had a release since 22-Sep-2009. As of 16-Mar-2011, it looks like a new version of wget will be released "soon", which will contain this patch. wget (1.13.4-1) is now available in the OpenWRT repositories.
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.
mkdir -p /etc/ssl/certs
/etc/profileand add the line:
Note: if you need SSL in your DDNS client, look also here using.wget
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.
You can use opkg to install the certificates from the major CA
opkg install ca-certificatesNow you have the major root certificates installed in /etc/ssl/certs
Let say we want to install the root certificate authority for dyndns.org. The domain https://members.dyndns.org is signed by the
"Equifax" root certificate. 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
opkg install openssl-util
Now you can use either the manual method or the add-cert.sh 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.
cd /etc/ssl/certs openssl s_client -connect members.dyndns.org:443 < /dev/null > temporary.out openssl x509 -outform PEM < temporary.out > members.dyndns.org.cer ##### create link using the hash value from openssl ##### # store certificate hash value in HASH append .0 HASH=`openssl x509 -hash -noout -in members.dyndns.org.cer`.0 # create link ln -s members.dyndns.org.cer $HASH
Note: If another cert has the same hash use suffix
.2 instead of
.0. To see the hash value type
Place this script in a file named add-cert.sh, using an editor like vi or nano (if installed). ``chmod +x add-cert.sh`` to mark it executable, then use it like this:
wget example.com/certificate.cer ./add-cert.sh certificate.cer
#!/bin/sh # author: joda openssl=/usr/bin/openssl certdir=$SSL_CERT_DIR if [ ! -f $openssl ]; then echo "ERROR: Can't find $openssl. openssl-util installed?" >&2 fi if [[ "$1" = "-f" ]]; then overwrite=1 shift # remove $1 fi 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 else 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 fi
Solution: Move old wget until new wget is installed ("opkg install" needs wget)
Using SSH/Telnet shell:
ln -sf /bin/busybox /bin/wget rm /usr/bin/wget opkg install wget rm /bin/wget
— joda 2010/06/19 20:57
Example: wget https://members.dyndns.org/