Create SSL context once and free it on exit #14

Merged
jmcbray merged 2 commits from tobias/germinal:master into master 2020-06-13 15:41:57 -04:00
Showing only changes of commit 0884b8cba5 - Show all commits

Create SSL context once and free it on exit

Tobias Rautenkranz 2020-06-13 12:50:30 +02:00

View file

@ -72,10 +72,15 @@
(setf (gethash "gmi" mimes:*mime-db*) "text/gemini")
(write-line #?"Listening on ${host} port ${port}")
(force-output)
(with-global-context ((make-context :disabled-protocols (list +ssl-op-no-sslv2+ +ssl-op-no-sslv3+
+ssl-op-no-tlsv1+ +ssl-op-no-tlsv1-1+
+ssl-op-no-tlsv1-2+))
:auto-free-p t)
(usocket:socket-server host port #'gemini-handler ()
:multi-threading t
:element-type '(unsigned-byte 8)
:in-new-thread background))
:in-new-thread background)))
(defun start-cli ()
"Start the germinal server, taking config from the environment or command-line."
@ -170,12 +175,7 @@
(defun gemini-handler (stream)
"The main Gemini request handler. Sets up TLS and sets up request and response"
(handler-case
(let* ((cl+ssl::*ssl-global-context*
(make-context :disabled-protocols (list +ssl-op-no-sslv2+ +ssl-op-no-sslv3+
+ssl-op-no-tlsv1+ +ssl-op-no-tlsv1-1+
+ssl-op-no-tlsv1-2+)))
(tls-stream
(make-ssl-server-stream stream
(let* ((tls-stream (make-ssl-server-stream stream
:certificate *germinal-cert*
:key *germinal-cert-key*))
(request (read-line-crlf tls-stream))