3rdparties/software/cl+ssl-20200427-git/index.html (18493 bytes)
1 <?xml version="1.0" encoding="iso-8859-1"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 4 <head> 5 <title>CL+SSL</title> 6 <link rel="stylesheet" type="text/css" href="index.css"/> 7 </head> 8 <body> 9 <h1>CL+SSL</h1> 10 11 <p> 12 A Common Lisp interface to OpenSSL. 13 </p> 14 15 <h3>About</h3> 16 17 <p> 18 This library is a fork 19 of <a href="http://www.cliki.net/SSL-CMUCL">SSL-CMUCL</a>. The 20 original SSL-CMUCL source code was written by Eric Marsden and 21 includes contributions by Jochen Schmidt. Development into CL+SSL 22 was done by David Lichteblau. License: MIT-style. 23 </p> 24 25 <p> 26 Distinguishing features: CL+SSL is portable code based on CFFI and 27 gray streams. It defines its own libssl BIO method, so that SSL 28 I/O can be written over portable Lisp streams instead of bypassing 29 the streams and sending data over Unix file descriptors directly. 30 (But the traditional approach is still used if possible.) 31 </p> 32 33 <h3>Download</h3> 34 <p> 35 The library is available via <a href="http://www.quicklisp.org/">Quicklisp</a>. 36 </p> 37 38 <p> 39 The Git repository: <a href="https://github.com/cl-plus-ssl/cl-plus-ssl">https://github.com/cl-plus-ssl/cl-plus-ssl</a>. 40 </p> 41 <p> 42 Send bug reports to <a 43 href="mailto:cl-plus-ssl-devel@common-lisp.net">cl-plus-ssl-devel@common-lisp.net</a> 44 (<a 45 href="http://common-lisp.net/cgi-bin/mailman/listinfo/cl-plus-ssl-devel">list 46 information</a>). 47 </p> 48 49 <h3>OpenSSL Installation Hints</h3> 50 51 <h4>Debian</h4> 52 53 <p> 54 You need the <tt>libssl-dev</tt> package on Debian to 55 load this cl+ssl without manual configuration. 56 </p> 57 58 <h4>Windows</h4> 59 60 <p> 61 <a href="https://wiki.openssl.org/index.php/Binaries">https://wiki.openssl.org/index.php/Binaries</a> 62 lists several soruces of binary distributions. 63 64 For example, 65 <a href="http://www.slproweb.com/products/Win32OpenSSL.html">http://www.slproweb.com/products/Win32OpenSSL.html</a> 66 (slproweb.com is a 3rd party; if you have questions about the OpenSSL installer they provide, 67 please ask in the mailing list specified on the linked page). 68 </p> 69 70 <p> 71 If you chose to install the DLLs into the OpenSSL installation's 72 "bin" directory (recommended), then be sure to add the bin directory to your 73 PATH environment variable and restart your 74 session. e.g. "C:\Program Files\OpenSSL-Win64\bin" 75 </p> 76 77 78 <!-- 79 <p> 80 Comparison chart: 81 </p> 82 <table border="1" cellpadding="2" cellspacing="0"> 83 <thead> 84 <tr> 85 <th></th> 86 <th><b>FFI</b></th> 87 <th><b>Streams</b></th> 88 <th><b>Lisp-BIO</b></th> 89 </tr> 90 </thead> 91 <tr> 92 <td>CL+SSL</td> 93 <td>CFFI</td> 94 <td>gray<sup>1</sup>, buffering output</td> 95 <td>yes</td> 96 </tr> 97 <tr> 98 <td>CL-SSL</td> 99 <td>UFFI</td> 100 <td>gray, buffering I/O [<em>part of ACL-COMPAT</em>]</td> 101 <td>no</td> 102 </tr> 103 <tr> 104 <td>SSL-CMUCL</td> 105 <td>CMUCL/ALIEN</td> 106 <td>CMUCL, non-buffering</td> 107 <td>no</td> 108 </tr> 109 </table> 110 <p> 111 <sup>1</sup> Character I/O and external formats in CL+SSL 112 are provided 113 using <a href="http://weitz.de/flexi-streams/">flexi-streams</a>. 114 </p> 115 --> 116 117 <h3>API</h3> 118 <p> 119 <div class="def">Function CL+SSL:ENSURE-INITIALIZED (&key method (rand-seed nil))</div> 120 In most cases you <strong>do not</strong> need to call this function, because it is called 121 automatically. The only reason to call it explicitly is to supply the <tt>rand-seed</tt> parameter. 122 In this case do it before calling any other functions. 123 </p> 124 <p> 125 Keyword arguments: 126 </p> 127 <p> 128 <tt>method</tt>. Just leave its default value. 129 </p> 130 <p> 131 <tt>rand-seed</tt> is an octet sequence to initialize OpenSSL random number generator. 132 On many platforms, including Linux and Windows, it may be leaved NIL (default), 133 because OpenSSL initializes the random number generator from OS specific service. But for 134 example on Solaris it may be necessary to supply this value. The minimum length required 135 by OpenSSL is 128 bits. See here <a href="http://www.openssl.org/support/faq.html#USER1"> 136 http://www.openssl.org/support/faq.html#USER1</a> for the details. 137 </p> 138 <p> 139 Hint: do not use Common Lisp RANDOM function to generate the <tt>rand-seed</tt>, because the function 140 usually returns predictable values. 141 </p> 142 <p> 143 <pre class="def" style="font-family:normal;">Function CL+SSL:MAKE-CONTEXT (&key method 144 disabled-protocols 145 (options (list +SSL-OP-ALL+)) 146 (session-cache-mode +ssl-sess-cache-server+) 147 (verify-location :default) 148 (verify-depth 100) 149 (verify-mode +ssl-verify-peer+) 150 (verify-callback nil verify-callback-supplied-p) 151 (cipher-list +default-cipher-list+) 152 (pem-password-callback 'pem-password-callback))</pre> 153 </p> 154 <p> 155 Creates a new SSL_CTX using <a href="https://www.openssl.org/docs/manmaster/ssl/SSL_CTX_new.html"><tt>SSL_CTX_new</tt></a> 156 and initializes it according to the specified parameters. 157 After you're done using the context, don't forget to free it using <tt>ssl-ctx-free</tt>. 158 </p> 159 <p> 160 Exceptions: 161 </p> 162 <p> 163 <tt>ssl-error-initialize</tt>. When underlying SSL_CTX_new fails. 164 </p> 165 <p> 166 Keyword arguments: 167 </p> 168 <p> 169 <tt>method</tt>. Specifies which supported SSL/TLS to use. If not specified then TLS_method is used on OpenSSL versions supporing it (on legacy versions SSLv23_method is used). 170 </p> 171 <p> 172 <tt>disabled-protocols</tt>. List of +SSL-OP-NO-* constants. Denotes disabled SSL/TLS versions. 173 When <tt>method</tt> not specified defaults to (list +SSL-OP-NO-SSLv2+ +SSL-OP-NO-SSLv3+) 174 </p> 175 <p> 176 <tt>options</tt>. SSL context options list. Defaults to (list +SSL-OP-ALL+) 177 </p> 178 <p> 179 <tt>session-cache-mode</tt>. Enable/Disable session caching. Defaults to +SSL-SESS-CACHE-SERVER+ 180 </p> 181 <p> 182 <tt>verify-location</tt>. Location(s) to load CA from. 183 Possible values 184 <br> 185 <ul> 186 <li><tt>:default</tt> OpenSSL default directory and file will be loaded</li> 187 <li><tt>:default-file</tt> OpenSSL default file will be loaded. Requires OpenSSL >= 1.1.0.</li> 188 <li><tt>:default-dir</tt> OpenSSL default directory will be loaded. Requires OpenSSL >= 1.1.0.</li> 189 <li><tt>STRING</tt> Directory or file path to be loaded</li> 190 <li><tt>PATHNAME</tt> Directory or file path to be loaded</li> 191 <li><tt>(LIST (or STRING PATHNAME))</tt> List of directories or files to be loaded</li> 192 </ul> 193 </p> 194 <p> 195 <tt>verify-depth</tt>. Sets the maximum depth for the certificate chain verification that shall be allowed for context. 196 Defaults to 100. 197 </p> 198 <p> 199 <tt>verify-mode</tt>. Sets the verification flags for context to be mode. Available flags 200 <ul> 201 <li>+SSL-VERIFY-NONE+</li> 202 <li>+SSL-VERIFY-PEER+</li> 203 <li>+SSL-VERIFY-FAIL-IF-NO-PEER-CERT+</li> 204 <li>+SSL-VERIFY-CLIENT-ONCE+</li> 205 </ul> 206 Defaults to +VERIFY-PEER+ 207 </p> 208 <p> 209 <tt>verify-callback</tt>. The verify-callback is used to control the behaviour when the +SSL-VERIFY-PEER+ flag is set. 210 <br/> 211 Please note: this must be CFFI callback i.e. defined as <tt>(defcallback <name> :int ((ok :int) (ctx :pointer)) .. )</tt>. 212 <br/> 213 Defaults to <tt>verify-peer-callback</tt> which converts chain errors to <tt>ssl-error-verify</tt>. 214 </p> 215 <p> 216 <tt>cipher-list</tt>. Sets the list of available ciphers for context. 217 Possible values described <a href="https://www.openssl.org/docs/manmaster/apps/ciphers.html">here</a>. 218 <br/> 219 Default is expected to change overtime to provide highest security level. Do not rely on its exact value. 220 </p> 221 <p> 222 <tt>pem-password-callback</tt>. Sets the default password callback called when loading/storing a PEM certificate with encryption. 223 <br/> 224 Please note: this must be CFFI callback i.e. defined as <tt>(cffi:defcallback <name> :int 225 ((buf :pointer) (size :int) (rwflag :int) (unused :pointer)) .. )</tt>. 226 <br/> 227 Defaults to <tt>pem-password-callback</tt> which simply uses password provided by <tt>with-pem-password</tt>. 228 </p> 229 <p> 230 <div class="def">Function CL+SSL:SSL-CTX-FREE (context)</div> 231 Plain FFI binding for <a href="https://www.openssl.org/docs/manmaster/ssl/SSL_CTX_free.html">SSL_CTX_free<a>. 232 </p> 233 <p> 234 <div class="def">Macro CL+SSL:WITH-GLOBAL-CONTEXT ((context &key :auto-free-p) &body body)</div> 235 Executes <tt>body</tt> with <tt>*ssl-global-context*</tt> bound to <tt>context</tt>. 236 <br/> 237 If <tt>auto-free-p</tt> is true the context is freed using <tt>ssl-ctx-free</tt> before exit. 238 </p> 239 <p> 240 <div class="def">Function CL+SSL:MAKE-SSL-CLIENT-STREAM (fd-or-stream &key external-format certificate key password close-callback (unwrap-stream-p t) verify hostname)<br/><br/> 241 Function CL+SSL:MAKE-SSL-SERVER-STREAM (fd-or-stream &key external-format certificate key password close-callback (unwrap-stream-p t))</div> 242 Return an SSL stream for the client (server) 243 socket <tt>fd-or-stream</tt>. All reads and writes to this 244 stream will be pushed through the OpenSSL library. 245 </p> 246 <p> 247 Keyword arguments: 248 </p> 249 <p> 250 If <tt>fd-or-stream</tt> is a lisp stream, the SSL stream will 251 close it automatically. File descriptors are not closed 252 automatically. However, if <tt>close-callback</tt> is non-nil, it 253 will be called with zero arguments when the SSL stream is closed. 254 </p> 255 <p> 256 If <tt>unwrap-stream-p</tt> is true (the default), a stream for a 257 file descriptor will be replaced by that file descriptor 258 automatically. This is similar to passing the result 259 of <tt>stream-fd</tt> as an argument, except that a deadline 260 associated with the stream object will be taken into account, and 261 that the stream will be closed automatically. As with file 262 descriptor arguments, no I/O will actually be done on the stream 263 object. 264 </p> 265 <p> 266 <tt>certificate</tt> is the path to a file containing the PEM-encoded 267 certificate. 268 </p> 269 <p> 270 <tt>key</tt> is the path to the PEM-encoded key, which may be associated 271 with the passphrase <tt>password</tt>. 272 </p> 273 <p> 274 If <tt>external-format</tt> is <tt>nil</tt> (the default), a plain 275 <tt>(unsigned-byte 8)</tt> SSL stream is returned. With a 276 non-null <tt>external-format</tt>, a flexi-stream capable of 277 character I/O will be returned instead, with the specified value 278 as its initial external format. 279 </p> 280 <p> 281 <tt>verify</tt> can be specified either as NIL if no check should be performed, 282 <tt>:optional</tt> to verify the server's certificate if it presented one or 283 <tt>:required</tt> to verify the server's certificate 284 and fail if an invalid or no certificate was presented. 285 Defaults to <tt>*make-ssl-client-stream-verify-default*</tt> 286 which is initialized to <tt>:required</tt> 287 </p> 288 <p> 289 <tt>hostname</tt> if specified, will be sent by client during TLS negotiation, 290 according to the Server Name Indication (SNI) extension to the TLS. 291 When server handles several domain names, this extension enables the server 292 to choose certificate for right domain. Also the <tt>hostname></tt> is used for 293 hostname verification if verification is enabled by <tt>verify</tt>. 294 </p> 295 <p> 296 <div class="def">Variable *make-ssl-client-stream-verify-default* :required</div> 297 Helps to mitigate the change in default behaviour of 298 <tt>make-ssl-client-stream</tt> - previously it worked as if <tt>:verify nil</tt> 299 but then <tt>:verify :required</tt> became the default on non-Windows platforms. 300 Change this variable if you want the previous behaviour. 301 </p> 302 <p> 303 <div class="def">Function CL+SSL:USE-CERTIFICATE-CHAIN-FILE (certificate-chain-file)</div> 304 Loads a PEM encoded certificate chain file <tt>certificate-chain-file</tt> 305 and adds the chain to global context. The certificates must be sorted 306 starting with the subject's certificate (actual client or server certificate), 307 followed by intermediate CA certificates if applicable, and ending at 308 the highest level (root) CA. 309 </p> 310 <p> 311 Note: the RELOAD function clears the global 312 context and in particular the loaded certificate chain. 313 </p> 314 <p> 315 <div class="def">Function CL+SSL:RELOAD ()</div> 316 Reload <tt>libssl</tt>. Call this function after restarting a Lisp 317 core with CL+SSL dumped into it on Lisp implementations that do 318 not reload shared libraries automatically. 319 </p> 320 <p> 321 <div class="def"><a name="libs-already-loaded"> 322 *FEATURES* flag :CL+SSL-FOREIGN-LIBS-ALREADY-LOADED 323 </a></div> 324 Allows user to load libssl (and libeay32 on Windows) himself 325 thus choosing the foreigh library(-ies) path and version to load. 326 327 <p>If specified, neither loading of the cl+ssl ASDF system 328 nor (cl+ssl:reload) try to load the foreign libraries, 329 assuming user has loaded them already.</p> 330 331 <pre> 332 (cffi:load-foreign-library "libssl.so.1.0.0") 333 334 (let ((*features* (cons :cl+ssl-foreign-libs-already-loaded 335 *features*))) 336 337 (ql:quickload :a-system-which-depends-on-cl+ssl) 338 339 ;; or just load cl+ssl 340 (ql:quickload :cl+ssl)) 341 </pre> 342 343 </p> 344 <p> 345 <div class="def">Function CL+SSL:STREAM-FD (stream)</div> 346 Return <tt>stream</tt>'s file descriptor as an integer, if known. 347 Otherwise return <tt>stream</tt> itself. The result of this 348 function can be passed to <tt>make-ssl-client-stream</tt> 349 and <tt>make-ssl-server-stream</tt>. 350 </p> 351 <p> 352 <div class="def">Function CL+SSL:RANDOM-BYTES (count)</div> 353 Generates <tt>count</tt> cryptographically strong pseudo-random bytes. Returns 354 the bytes as a <tt>simple-array</tt> with <tt>element-type '(unsigned-byte 8)</tt>. 355 Signals an <tt>error</tt> in case of problems, for example when the OpenSSL 356 random number generator has not been seeded with enough randomness to ensure 357 an unpredictable byte sequence. 358 </p> 359 360 <h3>Portability</h3> 361 <p> 362 CL+SSL requires CFFI with callback support. 363 </p> 364 <p> 365 CL Test Grid results: <a href="https://common-lisp.net/project/cl-test-grid/library/cl+ssl.html">https://common-lisp.net/project/cl-test-grid/library/cl+ssl.html</a> 366 </p> 367 <h3>TODO</h3> 368 <ul> 369 <li>session caching</li> 370 <li>The FFI code for all platforms except clisp needs to be 371 rewritten. (update 2017-07-05: does it? why?)</li> 372 </ul> 373 <h3>News</h3> 374 <p> 375 2017-07-03 376 </p> 377 <ul> 378 <li> 379 Hostname verification added, thanks to Ilya Khaprov. 380 Default mode for <tt>make-ssl-client-stream</tt> is to verify the connection. 381 New keywrd argument <tt>verify</tt> is added to <tt>make-ssl-client-stream</tt> with the same possible values as Drakma uses for http request verification. 382 </li> 383 </ul> 384 <p> 385 201?-??-?? 386 </p> 387 <ul> 388 <li> 389 See <a href="https://github.com/cl-plus-ssl/cl-plus-ssl/commits/master">commits</a>. 390 </li> 391 </ul> 392 <p> 393 2011-05-22 394 </p> 395 <ul> 396 <li> 397 Added new public function RANDOM-BYTES. 398 </li> 399 </ul> 400 <p> 401 2011-05-22 402 </p> 403 <ul> 404 <li> 405 The source code repository is moved to Git. 406 </li> 407 </ul> 408 <p> 409 2011-03-25 410 </p> 411 <ul> 412 <li> 413 OpenSSL libraries names for OpenBSD, thanks to Thomas de Grivel. 414 </li> 415 </ul> 416 <p> 417 2010-05-26 418 </p> 419 <ul> 420 <li> 421 Fixed two bugs in LISTEN, thanks to Ron Garret. 422 </li> 423 </ul> 424 <p> 425 2009-09-17 426 </p> 427 <ul> 428 <li> 429 libssl loading on FreeBSD 7.2 fixed, thanks to Stian Sletner. 430 </li> 431 </ul> 432 <p> 433 2008-xx-yy 434 </p> 435 <ul> 436 <li> 437 Support for I/O deadlines (Clozure CL and SBCL). 438 </li> 439 <li> 440 Support for encrypted keys, thanks to Vsevolod Dyomkin. 441 </li> 442 <li> 443 Chained certificates support, thanks to Juhani R�nkimies. 444 </li> 445 <li> 446 More secure initialization of OpenSSL random number generator. 447 </li> 448 <li> 449 Minor CLISP-specific fixes. 450 </li> 451 </ul> 452 <p> 453 2007-xx-yy 454 </p> 455 <ul> 456 <li> 457 Fixed windows support, thanks to Matthew Kennedy and Anton Vodonosov. 458 </li> 459 </ul> 460 <p> 461 2007-07-07 462 </p> 463 <ul> 464 <li> 465 Improved CLISP support, thanks 466 to <a 467 href="http://web.kepibu.org/code/lisp/cl+ssl/">Pixel 468 // pinterface</a>, as well as client certificate support. 469 </li> 470 <li> 471 Re-introduced support for direct access to file descriptors as 472 an optimization. New function <tt>stream-fd</tt>. New keyword 473 argument <tt>close-callback</tt>. 474 </li> 475 </ul> 476 <p> 477 2007-01-16: CL+SSL is now available under an MIT-style license. 478 </p> 479 </body> 480 </html>