X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Ftls.el;h=d121bad6e488675c1689dd7fc458d21f9cd844cd;hb=7989c95f1542128384c3db2d4fdbf260175477f2;hp=a2cced94fe36bb4e140fc3173bef0ab3538b12a7;hpb=e6b31519e256eaa52280b45df80d5b436c1539b1;p=elisp%2Fgnus.git- diff --git a/lisp/tls.el b/lisp/tls.el index a2cced9..d121bad 100644 --- a/lisp/tls.el +++ b/lisp/tls.el @@ -1,6 +1,6 @@ ;;; tls.el --- TLS/SSL support via wrapper around GnuTLS -;; Copyright (C) 2003 Free Software Foundation, Inc. +;; Copyright (C) 1996-1999, 2003, 2004 Free Software Foundation, Inc. ;; Author: Simon Josefsson ;; Keywords: comm, tls, gnutls, ssl @@ -68,16 +68,48 @@ after successful negotiation." :group 'tls) (defcustom tls-process-connection-type nil - "*Value for `process-connection-type' to use when starting process." + "*Value for `process-connection-type' to use when starting TLS process." + :version "21.4" :type 'boolean :group 'tls) (defcustom tls-success "- Handshake was completed" "*Regular expression indicating completed TLS handshakes. The default is what GNUTLS's \"gnutls-cli\" outputs." + :version "21.4" :type 'regexp :group 'tls) +(defcustom tls-certtool-program (executable-find "certtool") + "Name of GnuTLS certtool. +Used by `tls-certificate-information'." + :version "21.4" + :type '(repeat string) + :group 'tls) + +(defun tls-certificate-information (der) + "Parse X.509 certificate in DER format into an assoc list." + (let ((certificate (concat "-----BEGIN CERTIFICATE-----\n" + (base64-encode-string der) + "\n-----END CERTIFICATE-----\n")) + (exit-code 0)) + (with-current-buffer (get-buffer-create " *certtool*") + (erase-buffer) + (insert certificate) + (setq exit-code (condition-case () + (call-process-region (point-min) (point-max) + tls-certtool-program + t (list (current-buffer) nil) t + "--certificate-info") + (error -1))) + (if (/= exit-code 0) + nil + (let ((vals nil)) + (goto-char (point-min)) + (while (re-search-forward "^\\([^:]+\\): \\(.*\\)" nil t) + (push (cons (match-string 1) (match-string 2)) vals)) + (nreverse vals)))))) + (defun open-tls-stream (name buffer host service) "Open a TLS connection for a service to a host. Returns a subprocess-object to represent the connection.