Changes to cert application.
authorplugd <plugd@thelambdalab.xyz>
Sun, 20 Aug 2023 22:07:06 +0000 (00:07 +0200)
committerplugd <plugd@thelambdalab.xyz>
Sun, 20 Aug 2023 22:07:06 +0000 (00:07 +0200)
elpher.el

index 608f09d..eb2e526 100644 (file)
--- a/elpher.el
+++ b/elpher.el
@@ -801,7 +801,8 @@ ERROR can be either an error object or a string."
   "If non-nil, use TLS to communicate with gopher servers.")
 
 (defvar elpher-client-certificate nil
-  "If non-nil, contains client certificate details to use for TLS connections.")
+  "If non-nil, contains details of client certificate to use for TLS connections.
+See `elpher-generate-certificate' for further info.")
 
 (defun elpher-process-cleanup ()
   "Immediately shut down any extant elpher process and timers."
@@ -1417,8 +1418,7 @@ that the response was malformed."
           (elpher-gemini-insert-text response-meta))
          (let ((chosen-certificate
                 (with-local-quit
-                  (elpher-acquire-client-certificate
-                   (elpher-address-to-url (elpher-page-address elpher-current-page))))))
+                  (elpher-acquire-client-certificate))))
            (unless chosen-certificate
              (error "Gemini server requires a client certificate and none was provided"))
            (setq-local elpher-client-certificate chosen-certificate))
@@ -1428,23 +1428,21 @@ that the response was malformed."
          (error "Gemini server response unknown: %s %s"
                 response-code response-meta))))))
 
-(defun elpher-acquire-client-certificate (url-prefix)
-  "Select a pre-defined client certificate or prompt for one.
+(defun elpher-acquire-client-certificate ()
+  "Select and activate a pre-defined client certificate or prompt for one.
 In this case, \"pre-defined\" means a certificate provided by
-the `elpher-certificate-map' variable.
-
-For this session, the certificate will remain active for all addresses
-having URLs begining with URL-PREFIX."
-  (let ((entry (assoc url-prefix
-                      elpher-certificate-map
-                      #'string-prefix-p)))
+the `elpher-certificate-map' variable."
+  (let* ((current-url (elpher-address-to-url (elpher-page-address elpher-current-page)))
+         (entry (assoc current-url
+                       elpher-certificate-map
+                       #'string-prefix-p)))
     (if entry
-        (let ((cert-url-prefix (car entry))
+        (let ((cert-url-regex (car entry))
               (cert-name (cadr entry)))
           (message "Using certificate \"%s\" specified in elpher-certificate-map with prefix \"%s\""
-                   cert-name cert-url-prefix)
-          (elpher-get-existing-certificate cert-name cert-url-prefix))
-      (elpher-prompt-for-client-certificate url-prefix))))
+                   cert-name cert-url-regex)
+          (elpher-get-existing-certificate cert-name cert-url-regex))
+      (elpher-prompt-for-client-certificate current-url))))
 
 (defun elpher--read-answer-polyfill (question answers)
   "Polyfill for `read-answer' in Emacs 26.1.