Gnus development mailing list
 help / color / mirror / Atom feed
From: Ulf Stegemann <ulf@zeitform.de>
Cc: ding@gnus.org, Simon Josefsson <simon@josefsson.org>
Subject: Re: ldap cert retrieval and pem encoding
Date: Tue, 31 May 2005 13:21:32 +0200	[thread overview]
Message-ID: <zf.upnacmbhc8z.fsf@zeitform.de> (raw)
In-Reply-To: <87y89vrb7r.fsf@seamus.arnested.dk> (Arne =?iso-8859-1?Q?J=F8?= =?iso-8859-1?Q?rgensen's?= message of "Tue, 31 May 2005 11:33:44 +0200")

Arne Jørgensen <arne@arnested.dk> wrote:

> I have implemented the above strategy.

Great!

> I had no way to test it (except that it still works with DER encoded
> certificates).
>
> The attached patch also includes the patch for LDAP handling in XEmacs
> (from some weeks ago).

Okay, I had to change two things (s.b.) and now it works very well ... for
both PEM and DER encoded certs.

[...]

> Index: lisp/smime.el
> ===================================================================
> RCS file: /usr/local/cvsroot/gnus/lisp/smime.el,v
> retrieving revision 7.11
> diff -u -p -r7.11 smime.el
> --- lisp/smime.el	17 May 2005 08:02:16 -0000	7.11
> +++ lisp/smime.el	31 May 2005 09:17:51 -0000
> @@ -578,9 +578,20 @@ A string or a list of strings is returne
>  				       host '("userCertificate") nil))
>  	(retbuf (generate-new-buffer (format "*certificate for %s*" mail)))
>  	cert)
> -    (if (> (length ldapresult) 1)
> +    (if (>= (length ldapresult) 1)
>  	(with-current-buffer retbuf
> -	  (setq cert (base64-encode-string (nth 1 (car (nth 1 ldapresult))) t))
> +	  ;; Certificates on LDAP servers _should_ be in DER format,
> +	  ;; but there are some servers out there that distributes the
> +	  ;; certificates in PEM format (with or without
> +	  ;; header/footer) so we try to handle them anyway.
> +	  (if (or (string= (substring (cadaar ldapresult) 0 27)
> +			   "-----BEGIN CERTIFICATE-----")
> +		  (condition-case nil
> +		      (base64-decode-string (cadaar ldapresult))
> +		    (error nil)))
> +	      (setq cert
> +		    (replace-regexp-in-string "\\(\n\||\r\\|-----BEGIN CERTIFICATE-----\\|-----END CERTIFICATE-----\\)" "" (cadaar ldapresult) t))

It seems that replace-regexp-in-string is not known to xemacs but only to
emacs.  Furthermore, there's a typo in the regex ('\||\r' instead of '\\|\r').
The following replacement does the job here (XEmacs 21.4 (patch 17)):

  (replace-in-string 
   (cadaar ldapresult) 
   "\\(\n\\|\r\\|-----BEGIN CERTIFICATE-----\\|-----END CERTIFICATE-----\\)"
   "" t))

> +	    (setq cert (base64-encode-string (cadaar ldapresult) t)))
>  	  (insert "-----BEGIN CERTIFICATE-----\n")
>  	  (let ((i 0) (len (length cert)))
>  	    (while (> (- len 64) i)


Ulf



  reply	other threads:[~2005-05-31 11:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-24 10:02 Ulf Stegemann
2005-05-24 14:18 ` Simon Josefsson
2005-05-26 22:31 ` Arne Jørgensen
2005-05-26 22:31 ` Arne Jørgensen
2005-05-27 15:58   ` Ulf Stegemann
2005-05-28 11:30     ` Arne Jørgensen
2005-05-28 11:53       ` Simon Josefsson
2005-05-30  8:39         ` Ulf Stegemann
2005-05-30  8:48           ` Arne Jørgensen
2005-05-31  9:33       ` Arne Jørgensen
2005-05-31 11:21         ` Ulf Stegemann [this message]
2005-05-31 11:29           ` Simon Josefsson
2005-05-31 11:48             ` Reiner Steib
2005-05-31 12:59               ` Arne Jørgensen
2005-05-31 12:01             ` Ulf Stegemann
2005-05-31 12:07               ` Simon Josefsson
2005-05-31 12:57           ` Arne Jørgensen
2005-05-31 13:13             ` Simon Josefsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=zf.upnacmbhc8z.fsf@zeitform.de \
    --to=ulf@zeitform.de \
    --cc=ding@gnus.org \
    --cc=simon@josefsson.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).