From 848ed6a0434e5f5288ba58f674b730a44a6839f5 Mon Sep 17 00:00:00 2001 From: cage Date: Sun, 17 Jan 2021 19:13:33 +0100 Subject: [PATCH] - [gemini] fixed test for checking valid cached value for certificate/key pair. The function to find a cached certificate/key or create a new pair retuns a multiple value. I was using multiple-value-list for getting the pairs certificate/key from said functions. Then i was checking the results of 'multiple-value-list' for null values to get the non correct pair, but that expression never return nil (was returning '(nil) instead). This was breaking the client autentication. --- src/gemini-viewer.lisp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/gemini-viewer.lisp b/src/gemini-viewer.lisp index 8a522eb..267251b 100644 --- a/src/gemini-viewer.lisp +++ b/src/gemini-viewer.lisp @@ -474,16 +474,21 @@ :streaming :running))) (fetch-cached-certificate (actual-iri) - (let* ((certificate-and-key - (or (multiple-value-list - (db:ssl-cert-find actual-iri)) - (multiple-value-list - (gemini-client:make-client-certificate actual-iri)))) - (certificate (first certificate-and-key)) - (key (second certificate-and-key))) - (assert certificate) - (assert key) - (values certificate key))) + (let ((certificate nil) + (key nil)) + (multiple-value-bind (certificate-cache key-cache) + (db:ssl-cert-find actual-iri) + (if (and certificate-cache + key-cache) + (setf certificate certificate-cache + key key-cache) + (multiple-value-bind (certificate-new key-new) + (gemini-client:make-client-certificate actual-iri) + (setf certificate certificate-new + key key-new))) + (assert certificate) + (assert key) + (values certificate key)))) (get-user-input (hide-input host prompt) (flet ((on-input-complete (input) (when (string-not-empty-p input)