From 93c1b6cc4d49af4db4a629df20f4592fa78a3cdf Mon Sep 17 00:00:00 2001 From: Secret Specter Date: Mon, 14 Aug 2023 22:50:36 -0600 Subject: [PATCH] connection handler-case --- src/server.lisp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/server.lisp b/src/server.lisp index 15056c1..7cee1ab 100644 --- a/src/server.lisp +++ b/src/server.lisp @@ -1,4 +1,5 @@ (in-package #:geml.server) + (defun ensure-cert (certs-dir) (lambda (setting) (let* ((domain (string-downcase (symbol-name (car setting)))) @@ -87,12 +88,14 @@ ;; * https://en.wikipedia.org/wiki/Server_Name_Indication (let* ((domain (string-downcase (car (first (without-global settings))))) - (tls-conn (cl+ssl:make-ssl-server-stream - (usocket:socket-stream - (usocket:socket-accept server)) - :external-format '(:utf-8 :eol-style :crlf) - :certificate (format nil "~A~A.crt" certs-dir domain) - :key (format nil "~A~A.key" certs-dir domain)))) + (tls-conn (handler-case (cl+ssl:make-ssl-server-stream + (usocket:socket-stream + (usocket:socket-accept server)) + :external-format '(:utf-8 :eol-style :crlf) + :certificate (format nil "~A~A.crt" certs-dir domain) + :key (format nil "~A~A.key" certs-dir domain)) + ;; TODO handle more specific cases + (error (c) (format t "TLS Error: ~A~%" c))))) (unwind-protect (handle-request tls-conn settings) (close tls-conn)))))