(mml-smime-encrypt-buffer): Support certfiles stored in buffers.
authorSimon Josefsson <jas@extundo.com>
Sat, 28 Oct 2000 17:25:08 +0000 (17:25 +0000)
committerSimon Josefsson <jas@extundo.com>
Sat, 28 Oct 2000 17:25:08 +0000 (17:25 +0000)
(mml-secure-dns-server): Removed.
(mml-secure-part-smime-encrypt-by-dns): Use DIG interface.  Don't write
certificates to files.

lisp/ChangeLog
lisp/mml-sec.el

index 05f1798..c9931f0 100644 (file)
@@ -1,5 +1,11 @@
 2000-10-28  Simon Josefsson  <sj@extundo.com>
 
+       * mml-sec.el (mml-smime-encrypt-buffer): Support certfiles stored
+       in buffers.
+       (mml-secure-dns-server): Removed.
+       (mml-secure-part-smime-encrypt-by-dns): Use DIG interface.  Don't
+       write certificates to files.
+
        * smime.el (smime-dns-server): New variable.
        (smime-mail-to-domain):
        (smime-cert-by-dns): New functions.
index b79737b..e7d9d03 100644 (file)
       (error "Signing failed... inspect message logs for errors")))
 
 (defun mml-smime-encrypt-buffer (cont)
-  (or (smime-encrypt-buffer (list (cdr (assq 'certfile cont))))
-      (error "Encryption failed... inspect message logs for errors")))
+  (let (certnames certfiles tmp file tmpfiles)
+    (while (setq tmp (pop cont))
+      (if (and (consp tmp) (eq (car tmp) 'certfile))
+         (push (cdr tmp) certnames)))
+    (while (setq tmp (pop certnames))
+      (if (not (and (not (file-exists-p tmp))
+                   (get-buffer tmp)))
+         (push tmp certfiles)
+       (setq file (make-temp-name mm-tmp-directory))
+       (with-current-buffer tmp
+         (write-region (point-min) (point-max) file))
+       (push file certfiles)
+       (push file tmpfiles)))
+    (if (smime-encrypt-buffer certfiles)
+       (while (setq tmp (pop tmpfiles))
+         (delete-file tmp))
+      (while (setq tmp (pop tmpfiles))
+       (delete-file tmp))
+      (error "Encryption failed... inspect message logs for errors"))))
 
 (defun mml-pgpmime-sign-buffer (cont)
   (or (mml2015-mailcrypt-sign cont)
                     "File with recipient's S/MIME certificate: "
                     smime-certificate-directory nil t ""))))
 
-(defcustom mml-secure-dns-server ""
-  "DNS server to query certificates from."
-  :type 'string)
 
 (defun mml-secure-part-smime-encrypt-by-dns ()
-  ;; todo: deal with multiple recipients better
-  (let* ((file (make-temp-name (expand-file-name "mml." mm-tmp-directory)))
-        (buf (create-file-buffer file))
-        result who bad)
+  ;; todo: deal with comma separated multiple recipients
+  (let (result who bad cert)
     (condition-case ()
        (while (not result)
-         (setq who (read-from-minibuffer 
+         (setq who (read-from-minibuffer
                     (format "%sLookup certificate for: " (or bad ""))
                     (cadr (funcall gnus-extract-address-components 
                                    (or (save-excursion
                                            (message-narrow-to-headers)
                                            (message-fetch-field "to")))
                                        "")))))
-         (if (eq (call-process "dnscert" nil buf nil who
-                               mml-secure-dns-server)
-                 0)
-             (with-current-buffer buf
-               (write-region (point-min) (point-max) file)
-               (setq result (list 'certfile file)))
+         (if (setq cert (smime-cert-by-dns who))
+             (setq result (list 'certfile (buffer-name cert)))
            (setq bad (format "`%s' not found. " who))))
       (quit))
-    (kill-buffer buf)
     result))
 
 (defun mml-secure-part-smime-encrypt ()