make_sni.sh revision 1fb799609e09dd1df20777bef567d27059d90202
842ae4bd224140319ae7feec1872b93dfd491143fielding# Licensed to the Apache Software Foundation (ASF) under one or more
842ae4bd224140319ae7feec1872b93dfd491143fielding# contributor license agreements. See the NOTICE file distributed with
842ae4bd224140319ae7feec1872b93dfd491143fielding# this work for additional information regarding copyright ownership.
842ae4bd224140319ae7feec1872b93dfd491143fielding# The ASF licenses this file to You under the Apache License, Version 2.0
dc9d4f49d36e64c0157d930cb22ca82a6291c0cbdgaudet# (the "License"); you may not use this file except in compliance with
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd# the License. You may obtain a copy of the License at
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd# Unless required by applicable law or agreed to in writing, software
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd# distributed under the License is distributed on an "AS IS" BASIS,
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dc9d4f49d36e64c0157d930cb22ca82a6291c0cbdgaudet# See the License for the specific language governing permissions and
dc9d4f49d36e64c0157d930cb22ca82a6291c0cbdgaudet# limitations under the License.
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh# This script will populate a directory 'sni' with 3 sites, httpd.conf
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh# and certificates as to facilitate testing of TLS server name
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh# indication support (RFC 4366) or SNI.
ab5581cc78e9d865b0a6ab1404c53347b3276968rbb# List of hostnames automatically created by default.
ab5581cc78e9d865b0a6ab1404c53347b3276968rbb# IP address these hostnames are bound to.
1075efe007e7af339bde09cbb175d4f4d676eeb5rpluemif [ $? != 0 ]; then
029cfcadd33649e610c939d106dec96ca7f27bacniq echo "Syntax: $0 [-f] [-a IPaddress] [-d outdir] [-D domain ] [two or more vhost names ]"
dc9d4f49d36e64c0157d930cb22ca82a6291c0cbdgaudet echo " -f Force overwriting of outdir (default is $DIR)"
6e954603b02f2b7d4ad80af17d9b3cc6f0bacf69rbb echo " -d dir Directory to create the SNI test server in (default is $DIR)"
8a944f317ca393b84b03922a1eee0910cbd55aa3rbb echo " -D domain Domain name to use for this test (default is $DOMAIN)"
8a944f317ca393b84b03922a1eee0910cbd55aa3rbb echo " -a IP IP address to use for this virtual host (default is $IP)"
742318b93e89c311f66b55f426c4d9cf2c14628bjim echo " [names] List of optional vhost names (default is $NAMES)"
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh echo "Example:"
8a944f317ca393b84b03922a1eee0910cbd55aa3rbb echo " $0 -D SecureBlogsAreUs.com peter fred mary jane ardy"
dc9d4f49d36e64c0157d930cb22ca82a6291c0cbdgaudet echo "Which will create peter.SecureBlogsAreUs.com, fred.SecureBlogsAreUs.com and"
8a944f317ca393b84b03922a1eee0910cbd55aa3rbb echo "so on. Note that the _first_ FQDN is also the default for non SNI hosts. It"
8a944f317ca393b84b03922a1eee0910cbd55aa3rbb echo "may make sense to give this host a generic name - and allow each of the real"
8a944f317ca393b84b03922a1eee0910cbd55aa3rbb echo "SNI site as sub directories/URI's of this generic name; thus allowing the "
dc9d4f49d36e64c0157d930cb22ca82a6291c0cbdgaudet echo "few non-SNI browsers access."
029cfcadd33649e610c939d106dec96ca7f27bacniq shift; break;
8a944f317ca393b84b03922a1eee0910cbd55aa3rbbif [ $# = 1 ]; then
8a944f317ca393b84b03922a1eee0910cbd55aa3rbb echo "Aborted - just specifing one vhost makes no sense for SNI testing. Go wild !"
e8fcc872d5caeea36adb6511f9d1ab6ce3fbb5c0jerenkrantz echo Aborted - your openssl is very old or misconfigured.
8a944f317ca393b84b03922a1eee0910cbd55aa3rbb echo Aborted - version of openssl too old, 0.9 or up required.
a742cbb3e85669473b3233f30e3978bb6a20083cylavic echo Aborted - already an ${DIR} directory. Use the -f flag to overwrite.
a742cbb3e85669473b3233f30e3978bb6a20083cylavicmkdir -p ${DIR}/ssl ${DIR}/htdocs ${DIR}/logs || exit 1
a742cbb3e85669473b3233f30e3978bb6a20083cylavic# Create a 'CA' - keep using different serial numbers
a742cbb3e85669473b3233f30e3978bb6a20083cylavic# as the browsers get upset if they see an identical
a742cbb3e85669473b3233f30e3978bb6a20083cylavic# serial with a different pub-key.
a742cbb3e85669473b3233f30e3978bb6a20083cylavic# Note that we're not relying on the 'v3_ca' section as
a742cbb3e85669473b3233f30e3978bb6a20083cylavic# in the default openssl.conf file - so the certificate
a742cbb3e85669473b3233f30e3978bb6a20083cylavic# will be without the basicConstraints = CA:true and
a742cbb3e85669473b3233f30e3978bb6a20083cylavic# keyUsage = cRLSign, keyCertSign values. This is fine
3c990331fc6702119e4f5b8ba9eae3021aea5265jim# for most browsers.
d540257904755584099edb7c66387a25c3503ccftrawick -days 10 -subj '/CN=Da Root/O=SNI testing/' -set_serial $serial \
a742cbb3e85669473b3233f30e3978bb6a20083cylavic# Create the header for the example '/etc/hosts' file.
d540257904755584099edb7c66387a25c3503ccftrawick# Create a header for the httpd.conf snipped.
8a944f317ca393b84b03922a1eee0910cbd55aa3rbb# To append to your httpd.conf file'
8a944f317ca393b84b03922a1eee0910cbd55aa3rbbListen ${IP}:443
8a944f317ca393b84b03922a1eee0910cbd55aa3rbbNameVirtualHost ${IP}:443
8a944f317ca393b84b03922a1eee0910cbd55aa3rbbLoadModule ssl_module modules/mod_ssl.so
742318b93e89c311f66b55f426c4d9cf2c14628bjimSSLRandomSeed startup builtin
4b9d04712f3c887072645f9a628888998908467bjerenkrantzSSLRandomSeed connect builtin
742318b93e89c311f66b55f426c4d9cf2c14628bjimLogLevel debug
89211a3153be8b03353c3bfbca45fed67cb80f0bpquernaTransferLog ${DIR}/logs/access_log
4b9d04712f3c887072645f9a628888998908467bjerenkrantzErrorLog ${DIR}/logs/error_log
275419d6395e6f072962fb701b89accaff1f3690jerenkrantz# You'll get a warning about this.
275419d6395e6f072962fb701b89accaff1f3690jerenkrantzSSLSessionCache none
11e076839c8d5a82d55e710194d0daac51390dbdsf# Note that this SSL configuration is far
66d349e02d1a5a599a01c977d2c5b0009181f7deben# from complete - you propably will want
66d349e02d1a5a599a01c977d2c5b0009181f7deben# to configure SSLMutex-es and SSLSession
a742cbb3e85669473b3233f30e3978bb6a20083cylavic# Caches at the very least.
89211a3153be8b03353c3bfbca45fed67cb80f0bpquerna<Directory />
89211a3153be8b03353c3bfbca45fed67cb80f0bpquerna Options None
66d349e02d1a5a599a01c977d2c5b0009181f7deben AllowOverride None
275419d6395e6f072962fb701b89accaff1f3690jerenkrantz Require all denied
dc9d4f49d36e64c0157d930cb22ca82a6291c0cbdgaudet<Directory "${DIR}/htdocs">
1075efe007e7af339bde09cbb175d4f4d676eeb5rpluem allow from all
1075efe007e7af339bde09cbb175d4f4d676eeb5rpluem Require all granted
1075efe007e7af339bde09cbb175d4f4d676eeb5rpluem</Directory>
dc9d4f49d36e64c0157d930cb22ca82a6291c0cbdgaudet# This first entry is also the default for non SNI
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh# supporting clients.
set -- ${NAMES}
cat << EOM