Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Reply-To: From: "Ralf Hauser" To: Cc: Subject: RE: "contents altered after message signed" when sending openssl smime signed messages - SOLVED Date: Sun, 10 Aug 2003 11:44:07 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal In-Reply-To: X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Importance: Normal Summary of problem: -------------------- 1) "Wrong linefeeds" and 2) "extra lines" by ssmtp prevented messages signed by openssl in with a detached signature to be seen as valid by outlook. Solution: --------- Re 1) Brian suggested "u2d" and "d2u" and it seems that this works (although these programs unfortunately have no "-o" parameter to specify the output file ==> your original input may be gone due to "in-place" replacements before you really understand how u2d works ;) ) Re 2) As I chose a perl approach to solve the 2nd problem by replacing ssmtp, I am doing the linefeed fix in that perl script now too! As per Steve' suggestion, I first did perl -MCPAN -e 'install Net::SMTP' Then I wrote the attached script - it works nicely for my sample test case, but I certainly would need a lot more work to be fully useable: <> Remaining ToDo's (at least): i) deal with multiple recipients in the To, Cc, Bcc fields ii) I have to put CRT-ENTER after my signing password, with just "ENTER" openssl declares my signing password to be invalid. Hope this (maybe a little bit too long) thread is useful to other cygwin users who might want to use openssl to sign a message. If I get improvement suggestions for the below scripts, I am happy to make the most recent and IMHO best version of the perl script available via a URL. #!/usr/bin/perl -w # # CONFIGURATION SECTION $smtpHost='localhost'; $fromDomain='acm.org'; ################################ $lineCounter=0; while ( $line=<> ) { $line =~ s/$/\r/ ; if ($lineCounter == 1 ) { $line=~ /From:\s([^\s]+)/ ; $sender=$1; if ($sender eq "" ) { print STDERR "No sender specified in second line!\n"; exit(0); } # printing the warning only here because it might interfere # with openssl dialogs print STDERR "Warning: make sure, exim is running on $smtpHost or specify any other smtp server that doesn't ask for auth or TLS!\n\n/usr/bin/exim -bd -q30m\n"; use Net::SMTP; $smtp = Net::SMTP->new($smtpHost # the next 3 lines are optional! # , Hello => $fromDomain, # Timeout => 30, # Debug => 1, ); $smtp->mail($sender); $smtp->to($recipient); $lineCounter++; $smtp->data(); $smtp->datasend("$line0"); $smtp->datasend("$line"); } if ($lineCounter == 0 ) { $line=~ /To:\s([^\s]+)/ ; $recipient=$1; $line0=$line; $lineCounter++; if ($recipient eq "" ) { print STDERR "No recipient specified in first line!\n"; exit(0); } } if ($lineCounter > 1 ) { $smtp->datasend("$line"); $lineCounter++; } } $smtp->dataend(); $smtp->quit; # don't erase this line, otherwise, perl will complain about a variable been used # only once print STDERR "Message sent from domain \"$fromDomain\"!\n"; -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/