make_sni.sh revision 11f2c481e1d57bedb3f758565307501e9a2730dd
# limitations under the License. # This script will populate a directory 'sni' with 3 sites, httpd.conf # and certificates as to facilitate testing of TLS server name # indication support (RFC 4366) or SNI. # List of hostnames automatically created by default. # IP address these hostnames are bound to. # A certificate password for the .p12 files of the client # authentication test. Normally not set. However some browsers # require a password of at least 4 characters. echo "Syntax: $0 [-f] [-a IPaddress] [-d outdir] [-D domain ] [two or more vhost names ]" echo " -f Force overwriting of outdir (default is $DIR)" echo " -d dir Directory to create the SNI test server in (default is $DIR)" echo " -D domain Domain name to use for this test (default is $DOMAIN)" echo " -a IP IP address to use for this virtual host (default is $IP)" echo " -p str Password for the client certificate test (some browsers require a set password)" echo " [names] List of optional vhost names (default is $NAMES)" echo "so on. Note that the _first_ FQDN is also the default for non SNI hosts. It" echo "may make sense to give this host a generic name - and allow each of the real" echo "SNI site as sub directories/URI's of this generic name; thus allowing the " echo "few non-SNI browsers access." echo "Aborted - just specifing one vhost makes no sense for SNI testing. Go wild !" if test "0$2" \<
"00.9";
then # Create a 'CA' - keep using different serial numbers # as the browsers get upset if they see an identical # serial with a different pub-key. # Note that we're not relying on the 'v3_ca' section as # will be without the basicConstraints = CA:true and # keyUsage = cRLSign, keyCertSign values. This is fine # Create some certificate authorities for testing client controls # Create a chain of just the two access authorites: # And likewise a directory with the same information (using the # required 'hash' naming format # Use the above two client certificate authorities to make a few users # Create a certificate request for a test user. -
days 9 -
subj "/CN=User $i/O=SNI Test Crash Dummy Dept/" \
# And get it signed by either our client cert issuing root authority. # And create a pkcs#12 version for easy browser import. # Create the header for the example '/etc/hosts' file. echo '# To append to your hosts file' > ${
DIR}/
hosts # To append to your httpd.conf file' NameVirtualHost ${IP}:443 LoadModule ssl_module modules/mod_ssl.so SSLRandomSeed startup builtin SSLRandomSeed connect builtin TransferLog ${DIR}/logs/access_log ErrorLog ${DIR}/logs/error_log # You'll get a warning about this. # Note that this SSL configuration is far # from complete - you propably will want # to configure SSLSession Caches at the <Directory "${DIR}/htdocs"> # This first entry is also the default for non SNI # Create the header of a sample BIND zone file. echo "; Configuration sample to be added to the $DOMAIN zone file of BIND." INFO=
"and also the site you see when the browser does not support SNI." # Create a certificate request for this host. # And get it signed by our root authority. # Combine the key and certificate in one file. # Create a /etc/host and bind-zone file example # Create and populate a docroot for this host. INFO=
"and you'd normally only see this site when there is proper SNI support." # And create a configuration snipped. DocumentRoot ${DIR}/htdocs/$n SSLCertificateChainFile ${DIR}/root.pem SSLCertificateFile ${DIR}/ssl/$n.crt # Uncomment the following lines if you # want to only allow access to clients with # a certificate issued/signed by some # selection of the issuing authorites # SSLCACertificate ${CDIR}/xs-root-1.pem # just root 1 # SSLCACertificate ${CDIR}/xs-root-2.pem # just root 2 # SSLCACertificate ${CDIR}/xs-root-chain.pem # 1 & 2 # SSLCACertificateDir ${CDIR}/xs-root-dir # 1 & 2 - but as a directory. # SSLVerifyClient require TransferLog ${DIR}/logs/access_$n The directory ${DIR}/sni has been populated with the following - root.key|pem Certificate authority root and key. (You could import the root.pem key into your browser to quell warnings about an unknown authority). - hosts /etc/hosts file with fake entries for the hosts - htdocs directory with one docroot for each domain, each with a small sample file. - ssl directory with an ssl cert (signed by root) for each of the domains). - logs logfiles, one for each domain and an access_log for any misses. The directory ${CDIR} contains optional test files to allow client - client*pem/p12 Files for client authentication testing. These need to be imported into the browser. - xs-root-1/2 Certificate authority which has issued above client authentication certificates. - xs-root-dir A directory specific for the SSLCACertificateDir - xs-root-chain A chain of the two client xs authorities for the SSLCACertificate directive. A directory ${DIR}/sni has been created. Run an apache .../httpd -f ${DIR}/httpd-sni.conf and keep an eye on ${DIR}/logs/error_log. When everything is fine you will see entries like: Feb 11 16:12:26 2008] [debug] Init: SSL server IP/port overlap: ape.*:443 (httpd-sni.conf:24) vs. jane.*:443 (httpd-sni.conf:42) for each vhost configured and a concluding warning: [Mon Feb 11 16:12:26 2008] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) HOWEVER - If you see an entry like: [Mon Feb 11 15:41:41 2008] [warn] Init: You should not use name-based virtual hosts in conjunction with SSL!! then you are either using an OpenSSL which is too old and/or you need to ensure that the TLS Extensions are compiled into openssl with the 'enable-tlsext' flag. Once you have recompiled or reinstalled OpenSSL with TLS Extensions you will have to recompile mod_ssl to allow it to recognize SNI support. Meanwhile add 'hosts' to your c:\windows\system32\drivers\etc\hosts or /etc/hosts file as to point the various URL's to your server: and verify that each returns its own name (and an entry in its Note that in the generated example the 'first' domain is special - and is the catch all for non-SNI browsers. Depending on your circumstances it may make sense to use a generic name - and have each of the SNI domains as subdirectories (and hence URI's under this generic name). Thus allowing non SNI browsers also