aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Josefsson2004-10-12 09:40:45 +0000
committerSimon Josefsson2004-10-12 09:40:45 +0000
commit18965008d19ace53d4adea3eec5ea1168a7e3942 (patch)
treee9242fa8ff370aabdc05a0ba9ca1e378174d419f
parent170b174caeef3b0660938c63f6a0373cc7d5b6c3 (diff)
downloademacs-18965008d19ace53d4adea3eec5ea1168a7e3942.tar.gz
emacs-18965008d19ace53d4adea3eec5ea1168a7e3942.zip
(tls-certtool-program): New variable.
(tls-certificate-information): New function, based on ssl-certificate-information.
-rw-r--r--lisp/net/tls.el31
1 files changed, 30 insertions, 1 deletions
diff --git a/lisp/net/tls.el b/lisp/net/tls.el
index d7c8a47a2c0..5f57c084f9b 100644
--- a/lisp/net/tls.el
+++ b/lisp/net/tls.el
@@ -1,6 +1,6 @@
1;;; tls.el --- TLS/SSL support via wrapper around GnuTLS 1;;; tls.el --- TLS/SSL support via wrapper around GnuTLS
2 2
3;; Copyright (C) 2003 Free Software Foundation, Inc. 3;; Copyright (C) 1996-1999, 2003, 2004 Free Software Foundation, Inc.
4 4
5;; Author: Simon Josefsson <simon@josefsson.org> 5;; Author: Simon Josefsson <simon@josefsson.org>
6;; Keywords: comm, tls, gnutls, ssl 6;; Keywords: comm, tls, gnutls, ssl
@@ -76,6 +76,35 @@ The default is what GNUTLS's \"gnutls-cli\" outputs."
76 :type 'regexp 76 :type 'regexp
77 :group 'tls) 77 :group 'tls)
78 78
79(defcustom tls-certtool-program (executable-find "certtool")
80 "Name of GnuTLS certtool.
81Used by `tls-certificate-information'."
82 :type '(repeat string)
83 :group 'tls)
84
85(defun tls-certificate-information (der)
86 "Parse X.509 certificate in DER format into an assoc list."
87 (let ((certificate (concat "-----BEGIN CERTIFICATE-----\n"
88 (base64-encode-string der)
89 "\n-----END CERTIFICATE-----\n"))
90 (exit-code 0))
91 (with-current-buffer (get-buffer-create " *certtool*")
92 (erase-buffer)
93 (insert certificate)
94 (setq exit-code (condition-case ()
95 (call-process-region (point-min) (point-max)
96 tls-certtool-program
97 t (list (current-buffer) nil) t
98 "--certificate-info")
99 (error -1)))
100 (if (/= exit-code 0)
101 nil
102 (let ((vals nil))
103 (goto-char (point-min))
104 (while (re-search-forward "^\\([^:]+\\): \\(.*\\)" nil t)
105 (push (cons (match-string 1) (match-string 2)) vals))
106 (nreverse vals))))))
107
79(defun open-tls-stream (name buffer host service) 108(defun open-tls-stream (name buffer host service)
80 "Open a TLS connection for a service to a host. 109 "Open a TLS connection for a service to a host.
81Returns a subprocess-object to represent the connection. 110Returns a subprocess-object to represent the connection.