From 7c9a8e3ee21d4f4c1f1040174dd09cb3723cb3f4 Mon Sep 17 00:00:00 2001 From: cage Date: Fri, 16 Apr 2021 15:03:58 +0200 Subject: [PATCH] - [gemini] allowed to connect to host using ip address instead of hostname. --- src/gemini/client.lisp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/gemini/client.lisp b/src/gemini/client.lisp index 147e13b..b7e0235 100644 --- a/src/gemini/client.lisp +++ b/src/gemini/client.lisp @@ -356,15 +356,19 @@ :fragment (percent-encode-fragment fragment))) (ctx (cl+ssl:make-context :verify-mode cl+ssl:+ssl-verify-none+))) (cl+ssl:with-global-context (ctx :auto-free-p t) - (when-let* ((socket (open-tls-socket host port)) - (stream (usocket:socket-stream socket)) - (ssl-stream (cl+ssl:make-ssl-client-stream stream - :certificate client-certificate - :key certificate-key - :external-format nil - :unwrap-stream-p t - :verify nil - :hostname host)) + (let* ((socket (open-tls-socket host port)) + (stream (usocket:socket-stream socket)) + (ssl-hostname (if (or (iri:ipv4-address-p host) + (iri:ipv6-address-p host)) + nil + host)) + (ssl-stream (cl+ssl:make-ssl-client-stream stream + :certificate client-certificate + :key certificate-key + :external-format nil + :unwrap-stream-p t + :verify nil + :hostname ssl-hostname)) (request (format nil "~a~a~a" iri #\return #\newline)) (cert-hash (crypto-shortcuts:sha512 (x509:dump-certificate ssl-stream)))) (debug-gemini "sending request ~a" request)