| 1 | Use SSL with PennMUSH |
|---|
| 2 | Revised: 11 August 2003 |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | As of version 1.7.7p17, PennMUSH supports SSL connections when linked |
|---|
| 6 | with the OpenSSL library (http://www.openssl.org). The following |
|---|
| 7 | features are supported: |
|---|
| 8 | |
|---|
| 9 | * Encrypted sessions using SSLv2, SSLv3, and TLSv1 protocols |
|---|
| 10 | with ephemeral Diffie-Hellman keying. |
|---|
| 11 | * Authentication of the server via certificates |
|---|
| 12 | * Authentication of the clients via certificates |
|---|
| 13 | |
|---|
| 14 | This document explains how to use SSL with PennMUSH, and covers |
|---|
| 15 | the following issues: |
|---|
| 16 | |
|---|
| 17 | I. An SSL overview |
|---|
| 18 | II. Compiling with OpenSSL |
|---|
| 19 | III. Mush configuration overview |
|---|
| 20 | IV. Installing a server certificate (required) |
|---|
| 21 | V. Using client certificates for authentication (optional) |
|---|
| 22 | VI. Legal issues |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | I. An SSL overview |
|---|
| 26 | |
|---|
| 27 | When an SSL client connects to an SSL server, it performs a |
|---|
| 28 | "handshake" that looks something like this: |
|---|
| 29 | |
|---|
| 30 | Client says hello, offers a menu of cipher options |
|---|
| 31 | Server says hello, selects a cipher. |
|---|
| 32 | Server presents its certificate, requests a client certificate |
|---|
| 33 | Client presents a certificate (or not) |
|---|
| 34 | Client and server exchange cryptographic session keys |
|---|
| 35 | |
|---|
| 36 | The server is identified to the client by a certificate, an encoded |
|---|
| 37 | text that gives the server's name and other attributes and is |
|---|
| 38 | signed by a certifying authority (CA), like Verisign. The client |
|---|
| 39 | checks that the signature is by a CA that it trusts, and may perform |
|---|
| 40 | other validation on the certificate (e.g., checking that the hostname |
|---|
| 41 | in the certificate matches the hostname it's trying to connect to). |
|---|
| 42 | |
|---|
| 43 | If the client chooses to present a certificate (or is required to |
|---|
| 44 | by the server), the server will likewise attempt to validate it |
|---|
| 45 | against its list of trusted CAs, and may perform other verification. |
|---|
| 46 | |
|---|
| 47 | Once session keys have been exchanged, the client and server can |
|---|
| 48 | communicate secure from eavesdropping. |
|---|
| 49 | |
|---|
| 50 | II. Compiling with OpenSSL |
|---|
| 51 | |
|---|
| 52 | The Configure script distributed with PennMUSH automatically detects |
|---|
| 53 | the OpenSSL libraries (libssl and libcrypto) and attempts to link |
|---|
| 54 | them into the executable, defining HAS_OPENSSL in config.h. |
|---|
| 55 | If you have SSL libraries but wish to avoid linking with them, |
|---|
| 56 | give the -D no_openssl argument to Configure when you run it. |
|---|
| 57 | |
|---|
| 58 | You can compile the OpenSSL libraries yourself from source code |
|---|
| 59 | at http://www.openssl.org. |
|---|
| 60 | |
|---|
| 61 | OpenSSL can also be compiled on Windows, and you could add its |
|---|
| 62 | libraries to the PennMUSH project file and link it in that way. |
|---|
| 63 | Noltar has done this succesfully; it requires compiling both |
|---|
| 64 | OpenSSL and PennMUSH in /MD (multithread dll) mode. |
|---|
| 65 | |
|---|
| 66 | III. Mush configuration overview |
|---|
| 67 | |
|---|
| 68 | mush.cnf includes three directives that configure the SSL support: |
|---|
| 69 | |
|---|
| 70 | ssl_port selects the port number for the MUSH to listen for SSL |
|---|
| 71 | connections. Any port number other than the MUSH's ordinary listening |
|---|
| 72 | port can be chosen (subject, of course, to other system restrictions |
|---|
| 73 | on choosing port numbers). |
|---|
| 74 | |
|---|
| 75 | ssl_private_key_file specifies the name of the file (relative to the |
|---|
| 76 | game/ directory if it's not an absolute path) that contains the |
|---|
| 77 | MUSH server's certificate and private key. See section IV below. |
|---|
| 78 | |
|---|
| 79 | ssl_ca_file specifies the name of the file that contains certificates |
|---|
| 80 | of trusted certificate authorities. OpenSSL distributes a file containing |
|---|
| 81 | the best known CAs that is suitable for use here. If you comment this |
|---|
| 82 | out, client certificate checking will not be performed. |
|---|
| 83 | |
|---|
| 84 | ssl_require_client_cert is a boolean option that controls whether the |
|---|
| 85 | MUSH server will require clients to present valid (that is, signed by |
|---|
| 86 | a CA for which ssl_ca_file holds a certificate) certificates in order |
|---|
| 87 | to connect. As no mud clients currently do this, you probably want it |
|---|
| 88 | off. See section V below. |
|---|
| 89 | |
|---|
| 90 | IV. Installing a server certificate |
|---|
| 91 | |
|---|
| 92 | SSL support requires that the MUSH present a server certificate (except |
|---|
| 93 | as discussed below). You must create a file containing the certificate |
|---|
| 94 | and the associated private key (stripped of any passphrase protection) |
|---|
| 95 | and point the ssl_private_key_file directive at this file. This file |
|---|
| 96 | should only be readable by the MUSH account! |
|---|
| 97 | |
|---|
| 98 | How do you get such a certificate and private key? Here are the |
|---|
| 99 | steps you can use with openssl's command-line tool: |
|---|
| 100 | |
|---|
| 101 | 1. Generate a certificate signing request (mymush.csr) and a private key |
|---|
| 102 | (temp.key). You will be asked to answer several questions. |
|---|
| 103 | Be sure the Common Name you request is your MUSH's hostname: |
|---|
| 104 | |
|---|
| 105 | $ openssl req -new -out mymush.csr -keyout temp.key -passin pass:foobar |
|---|
| 106 | |
|---|
| 107 | 2. Strip the passphrase off of your private key, leaving you |
|---|
| 108 | with an unpassworded mymush.key file: |
|---|
| 109 | |
|---|
| 110 | $ openssl rsa -in temp.key -out mymush.key -passin pass:foobar |
|---|
| 111 | $ rm temp.key |
|---|
| 112 | |
|---|
| 113 | 3. Send the certificate signing request to a certifying authority |
|---|
| 114 | to have it signed. If the CA needs the private key, send the |
|---|
| 115 | passphrased one. The CA will send you back a certificate |
|---|
| 116 | which you save to a file (mymush.crt) |
|---|
| 117 | |
|---|
| 118 | 4. Concatenate the certificate with the unpassworded private key and |
|---|
| 119 | use this as the ssl_private_key_file: |
|---|
| 120 | |
|---|
| 121 | $ cat mymush.key >> mymush.crt |
|---|
| 122 | |
|---|
| 123 | Commercial CAs like Verisign sign certificates for a yearly or two-yearly |
|---|
| 124 | fee that is probably too steep for most MUSH Gods. Instead of using |
|---|
| 125 | a commercial CA, you can generate a self-signed certificate by |
|---|
| 126 | changing step 1 above to: |
|---|
| 127 | |
|---|
| 128 | $ openssl req -new -x509 -days 3650 -out mymush.crt -keyout temp.key -passin pass:foobar |
|---|
| 129 | |
|---|
| 130 | A self-signed certificate is free, but clients that attempt to validate |
|---|
| 131 | certificates will fail to validate a self-signed certificate unless |
|---|
| 132 | the user manually installs the certificate in their client and configures |
|---|
| 133 | it to be trusted. How to do that is beyond the scope of this document, |
|---|
| 134 | and highly client-dependent. |
|---|
| 135 | |
|---|
| 136 | Another option is to skip the use of a certificate altogether. |
|---|
| 137 | If you don't provide an ssl_private_key_file, the server will only |
|---|
| 138 | accept connections from clients that are willing to use the |
|---|
| 139 | anonymous Diffie-Hellman cipher; it is unknown which clients |
|---|
| 140 | are configured to offer this. This provides clients with no |
|---|
| 141 | security that they are actually connecting to your server, and |
|---|
| 142 | exposes them to a man-in-the-middle attack, but requires no |
|---|
| 143 | work on your part at all. |
|---|
| 144 | |
|---|
| 145 | Hosting providers or other parties may one day provide CA service |
|---|
| 146 | to PennMUSHes for free. When they do, you'll have to install those |
|---|
| 147 | CAs' certificates in your client as trusted in order to have the |
|---|
| 148 | server's certificate validate, but if a few CAs certify many MUSHes, |
|---|
| 149 | this is efficient. |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | V. Using client certificates for authentication |
|---|
| 153 | |
|---|
| 154 | If you provide PennMUSH with a file containing the certificates of |
|---|
| 155 | trusted CAs (using the ssl_ca_file directive in mush.cnf), it will, |
|---|
| 156 | by default, request that clients present certificates when they connect. |
|---|
| 157 | Clients that do not present certificates will still be allowed to |
|---|
| 158 | connect (unless ssl_require_client_cert is enabled). |
|---|
| 159 | |
|---|
| 160 | Clients that do present certificates must present certificates signed |
|---|
| 161 | by a trusted CA, or they will be disconnected. Both valid and invalid |
|---|
| 162 | certificates are logged (to connect.log and netmush.log, respectively). |
|---|
| 163 | |
|---|
| 164 | If you were really serious about this, you probably would issue your |
|---|
| 165 | own certs and not allow Verisign, etc. certs. You'd probably want to |
|---|
| 166 | have the server validate extra attributes on each client cert, which |
|---|
| 167 | should probably include the player's dbref and creation time. This is |
|---|
| 168 | left as an exercise for the reader for now. |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | VI. Legal issues |
|---|
| 172 | |
|---|
| 173 | OpenSSL is used in PennMUSH and may be redistributed with PennMUSH |
|---|
| 174 | under the following license(s): |
|---|
| 175 | |
|---|
| 176 | OpenSSL License |
|---|
| 177 | --------------- |
|---|
| 178 | |
|---|
| 179 | /* ==================================================================== |
|---|
| 180 | * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. |
|---|
| 181 | * |
|---|
| 182 | * Redistribution and use in source and binary forms, with or without |
|---|
| 183 | * modification, are permitted provided that the following conditions |
|---|
| 184 | * are met: |
|---|
| 185 | * |
|---|
| 186 | * 1. Redistributions of source code must retain the above copyright |
|---|
| 187 | * notice, this list of conditions and the following disclaimer. |
|---|
| 188 | * |
|---|
| 189 | * 2. Redistributions in binary form must reproduce the above copyright |
|---|
| 190 | * notice, this list of conditions and the following disclaimer in |
|---|
| 191 | * the documentation and/or other materials provided with the |
|---|
| 192 | * distribution. |
|---|
| 193 | * |
|---|
| 194 | * 3. All advertising materials mentioning features or use of this |
|---|
| 195 | * software must display the following acknowledgment: |
|---|
| 196 | * "This product includes software developed by the OpenSSL Project |
|---|
| 197 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" |
|---|
| 198 | * |
|---|
| 199 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to |
|---|
| 200 | * endorse or promote products derived from this software without |
|---|
| 201 | * prior written permission. For written permission, please contact |
|---|
| 202 | * openssl-core@openssl.org. |
|---|
| 203 | * |
|---|
| 204 | * 5. Products derived from this software may not be called "OpenSSL" |
|---|
| 205 | * nor may "OpenSSL" appear in their names without prior written |
|---|
| 206 | * permission of the OpenSSL Project. |
|---|
| 207 | * |
|---|
| 208 | * 6. Redistributions of any form whatsoever must retain the following |
|---|
| 209 | * acknowledgment: |
|---|
| 210 | * "This product includes software developed by the OpenSSL Project |
|---|
| 211 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" |
|---|
| 212 | * |
|---|
| 213 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY |
|---|
| 214 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 215 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|---|
| 216 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR |
|---|
| 217 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|---|
| 218 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|---|
| 219 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|---|
| 220 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|---|
| 221 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
|---|
| 222 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 223 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
|---|
| 224 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 225 | * ==================================================================== |
|---|
| 226 | * |
|---|
| 227 | * This product includes cryptographic software written by Eric Young |
|---|
| 228 | * (eay@cryptsoft.com). This product includes software written by Tim |
|---|
| 229 | * Hudson (tjh@cryptsoft.com). |
|---|
| 230 | * |
|---|
| 231 | */ |
|---|
| 232 | |
|---|
| 233 | Original SSLeay License |
|---|
| 234 | ----------------------- |
|---|
| 235 | |
|---|
| 236 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
|---|
| 237 | * All rights reserved. |
|---|
| 238 | * |
|---|
| 239 | * This package is an SSL implementation written |
|---|
| 240 | * by Eric Young (eay@cryptsoft.com). |
|---|
| 241 | * The implementation was written so as to conform with Netscapes SSL. |
|---|
| 242 | * |
|---|
| 243 | * This library is free for commercial and non-commercial use as long as |
|---|
| 244 | * the following conditions are aheared to. The following conditions |
|---|
| 245 | * apply to all code found in this distribution, be it the RC4, RSA, |
|---|
| 246 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
|---|
| 247 | * included with this distribution is covered by the same copyright terms |
|---|
| 248 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
|---|
| 249 | * |
|---|
| 250 | * Copyright remains Eric Young's, and as such any Copyright notices in |
|---|
| 251 | * the code are not to be removed. |
|---|
| 252 | * If this package is used in a product, Eric Young should be given attribution |
|---|
| 253 | * as the author of the parts of the library used. |
|---|
| 254 | * This can be in the form of a textual message at program startup or |
|---|
| 255 | * in documentation (online or textual) provided with the package. |
|---|
| 256 | * |
|---|
| 257 | * Redistribution and use in source and binary forms, with or without |
|---|
| 258 | * modification, are permitted provided that the following conditions |
|---|
| 259 | * are met: |
|---|
| 260 | * 1. Redistributions of source code must retain the copyright |
|---|
| 261 | * notice, this list of conditions and the following disclaimer. |
|---|
| 262 | * 2. Redistributions in binary form must reproduce the above copyright |
|---|
| 263 | * notice, this list of conditions and the following disclaimer in the |
|---|
| 264 | * documentation and/or other materials provided with the distribution. |
|---|
| 265 | * 3. All advertising materials mentioning features or use of this software |
|---|
| 266 | * must display the following acknowledgement: |
|---|
| 267 | * "This product includes cryptographic software written by |
|---|
| 268 | * Eric Young (eay@cryptsoft.com)" |
|---|
| 269 | * The word 'cryptographic' can be left out if the rouines from the library |
|---|
| 270 | * being used are not cryptographic related :-). |
|---|
| 271 | * 4. If you include any Windows specific code (or a derivative thereof) from |
|---|
| 272 | * the apps directory (application code) you must include an acknowledgement: |
|---|
| 273 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
|---|
| 274 | * |
|---|
| 275 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
|---|
| 276 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 277 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 278 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|---|
| 279 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|---|
| 280 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|---|
| 281 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|---|
| 282 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|---|
| 283 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|---|
| 284 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|---|
| 285 | * SUCH DAMAGE. |
|---|
| 286 | * |
|---|
| 287 | * The licence and distribution terms for any publically available version or |
|---|
| 288 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
|---|
| 289 | * copied and put under another distribution licence |
|---|
| 290 | * [including the GNU Public Licence.] |
|---|
| 291 | */ |
|---|
| 292 | |
|---|
| 293 | |
|---|