;;; smime.el --- S/MIME support library
-;; Copyright (C) 2000-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2016 Free Software Foundation, Inc.
;; Author: Simon Josefsson <simon@josefsson.org>
;; Keywords: SMIME X.509 PEM OpenSSL
(eval-when-compile (require 'cl))
-(eval-and-compile
- (cond
- ((fboundp 'replace-in-string)
- (defalias 'smime-replace-in-string 'replace-in-string))
- ((fboundp 'replace-regexp-in-string)
- (defun smime-replace-in-string (string regexp newtext &optional literal)
- "Replace all matches for REGEXP with NEWTEXT in STRING.
-If LITERAL is non-nil, insert NEWTEXT literally. Return a new
-string containing the replacements.
-
-This is a compatibility function for different Emacsen."
- (replace-regexp-in-string regexp newtext string nil literal)))))
-
(defgroup smime nil
"S/MIME configuration."
:group 'mime)
Directory should contain files (in PEM format) named to the X.509
hash of the certificate. This can be done using OpenSSL such as:
-$ ln -s ca.pem `openssl x509 -noout -hash -in ca.pem`.0
+$ ln -s ca.pem \\=`openssl x509 -noout -hash -in ca.pem\\=`.0
where `ca.pem' is the file containing a PEM encoded X.509 CA
certificate."
(defvar smime-details-buffer "*OpenSSL output*")
-;; Use mm-util?
-(eval-and-compile
- (defalias 'smime-make-temp-file
- (if (fboundp 'make-temp-file)
- 'make-temp-file
- (lambda (prefix &optional dir-flag) ;; Simple implementation
- (expand-file-name
- (make-temp-name prefix)
- (if (fboundp 'temp-directory)
- (temp-directory)
- temporary-file-directory))))))
-
;; Password dialog function
(declare-function password-read-and-add "password-cache" (prompt &optional key))
(keyfile (or (car-safe keyfile) keyfile))
(buffer (generate-new-buffer " *smime*"))
(passphrase (smime-ask-passphrase (expand-file-name keyfile)))
- (tmpfile (smime-make-temp-file "smime")))
+ (tmpfile (make-temp-file "smime")))
(if passphrase
(setenv "GNUS_SMIME_PASSPHRASE" passphrase))
(prog1
is expected to contain of a PEM encoded certificate."
(smime-new-details-buffer)
(let ((buffer (generate-new-buffer " *smime*"))
- (tmpfile (smime-make-temp-file "smime")))
+ (tmpfile (make-temp-file "smime")))
(prog1
(when (prog1
(apply 'smime-call-openssl-region b e (list buffer tmpfile)
(smime-new-details-buffer)
(let ((buffer (generate-new-buffer " *smime*"))
CAs (passphrase (smime-ask-passphrase (expand-file-name keyfile)))
- (tmpfile (smime-make-temp-file "smime")))
+ (tmpfile (make-temp-file "smime")))
(if passphrase
(setenv "GNUS_SMIME_PASSPHRASE" passphrase))
(if (prog1
"Get certificate for MAIL from the ldap server at HOST."
(let ((ldapresult
(funcall
- (if (featurep 'xemacs)
- (progn
- (require 'smime-ldap)
- 'smime-ldap-search)
- (progn
- (require 'ldap)
- 'ldap-search))
+ (progn
+ (require 'ldap)
+ 'ldap-search)
(concat "mail=" mail)
host '("userCertificate") nil))
(retbuf (generate-new-buffer (format "*certificate for %s*" mail)))
(string= (substring (cadaar ldapresult) 0 3)
"MII"))
(setq cert
- (smime-replace-in-string
- (cadaar ldapresult)
+ (replace-regexp-in-string
(concat "\\(\n\\|\r\\|-----BEGIN CERTIFICATE-----\\|"
"-----END CERTIFICATE-----\\)")
- "" t))
+ ""
+ (cadaar ldapresult) nil t))
(setq cert (base64-encode-string (cadaar ldapresult) t)))
(insert "-----BEGIN CERTIFICATE-----\n")
(let ((i 0) (len (length cert)))