See ChangeLog

Monotone-Parent: fd4fbe52ae1095a87a517a53675370212526e1fc
Monotone-Revision: 7c4c9bea35b92f37ca95185837c77033a40c7cc6

Monotone-Author: ludovic@Sophos.ca
Monotone-Date: 2009-09-25T21:01:05
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Ludovic Marcotte
2009-09-25 21:01:05 +00:00
parent 7b22cc66a7
commit 129df380ee
5 changed files with 89 additions and 15 deletions

View File

@@ -13,6 +13,9 @@
* SoObjects/SOGo/LDAPSource.m
We trim the bind field value prior to adding it to our
LDAP search filter.
* UI/MailPartViewers/UIxMailPartSignedViewer.m and friends:
We now show more information on the S/MIME encoded messages.
We also handle correctly multipart/alternative messages.
2009-09-24 Cyril Robert <crobert@inverse.ca>

View File

@@ -25,7 +25,7 @@
#import "UIxMailPartViewer.h"
@class NSString;
@class NSMutableString;
@class NGPart;
@interface UIxMailPartSignedViewer : UIxMailPartViewer
@@ -34,13 +34,13 @@
NGPart *messagePart;
BOOL validSignature;
NSString *validationError;
NSMutableString *validationMessage;
}
- (NSString *) flatContentAsString;
- (BOOL) validSignature;
- (NSString *) validationError;
- (NSString *) validationMessage;
@end

View File

@@ -3,6 +3,7 @@
* Copyright (C) 2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Ludovic Marcotte <lmarcotte@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -153,6 +154,29 @@
content = [[body stringByDetectingURLs]
stringByConvertingCRLNToHTML];
}
else if ([mimeType isEqualToString: @"multipart/alternative"])
{
NSArray *parts;
int i;
parts = [(NGMimeMultipartBody *)[messagePart body] parts];
for (i = 0; i < [parts count]; i++)
{
mimeType = [[parts objectAtIndex: i] contentType];
if ([mimeType isEqualToString: @"text/plain"])
{
body = [[[parts objectAtIndex: i] body] stringByEscapingHTMLString];
content = [[body stringByDetectingURLs]
stringByConvertingCRLNToHTML];
break;
}
else
content = nil;
}
}
else
{
NSLog (@"unhandled mime type in multipart/signed: '%@'", mimeType);
@@ -201,12 +225,16 @@
- (void) _processMessage
{
BIO *msgBio, *inData;
X509_STORE *x509Store;
PKCS7 *p7;
int err;
NSString *issuer, *subject;
NSData *signedData;
STACK_OF(X509) *certs;
X509_STORE *x509Store;
BIO *msgBio, *inData;
char sslError[1024];
PKCS7 *p7;
int err, i;
*sslError = 0;
@@ -216,7 +244,41 @@
msgBio = BIO_new_mem_buf ((void *) [signedData bytes], [signedData length]);
inData = NULL;
p7 = SMIME_read_PKCS7 (msgBio, &inData);
p7 = SMIME_read_PKCS7(msgBio, &inData);
subject = nil;
issuer = nil;
certs = NULL;
i = OBJ_obj2nid(p7->type);
if (i == NID_pkcs7_signed)
{
X509 *x;
certs=p7->d.sign->cert;
if (sk_X509_num(certs) > 0)
{
BIO *buf;
char p[256];
memset(p, 0, 256);
x = sk_X509_value(certs,0);
buf = BIO_new(BIO_s_mem());
X509_NAME_print_ex(buf, X509_get_subject_name(x), 0, XN_FLAG_FN_SN);
BIO_gets(buf, p, 256);
subject = [NSString stringWithUTF8String: p];
memset(p, 0, 256);
X509_NAME_print_ex(buf, X509_get_issuer_name(x), 0, XN_FLAG_FN_SN);
BIO_gets(buf, p, 256);
issuer = [NSString stringWithUTF8String: p];
BIO_free(buf);
}
}
err = ERR_get_error();
if (err)
{
@@ -231,7 +293,7 @@
err = ERR_get_error();
if (err)
ERR_error_string_n (err, sslError, 1023);
ERR_error_string_n(err, sslError, 1023);
if (x509Store)
X509_STORE_free (x509Store);
@@ -241,9 +303,18 @@
if (inData)
BIO_free (inData);
if (!validSignature)
validationError = [NSString stringWithFormat: @"%s", sslError];
validationMessage = [NSMutableString string];
if (!validSignature)
[validationMessage appendString: [self labelForKey: @"Digital signature is not valid"]];
else
[validationMessage appendString: [self labelForKey: @"Message is signed"]];
if (issuer && subject)
[validationMessage appendFormat: @"\n%@: %@\n%@: %@",
[self labelForKey: @"Subject"], subject,
[self labelForKey: @"Issuer"], issuer];
processed = YES;
}
@@ -255,12 +326,12 @@
return validSignature;
}
- (NSString *) validationError
- (NSString *) validationMessage
{
if (!processed)
[self _processMessage];
return validationError;
return validationMessage;
}
@end

View File

@@ -8,6 +8,6 @@
class="mailer_plaincontent signed"
const:id="signedMessage"
var:valid="validSignature"
var:error="validationError"
var:error="validationMessage"
><var:string value="flatContentAsString" const:escapeHTML="NO"
/></div>

View File

@@ -992,7 +992,7 @@ function configureSignatureFlagImage() {
var msgDiv = $("signatureFlagMessage");
if (msgDiv && error) {
var formattedMessage = error.replace("\n", "<br/>");
var formattedMessage = error.replace(/\n/g, "<br/>");
msgDiv.innerHTML = "<div>" + formattedMessage + "</div>";
newImg.observe("mouseover", showSignatureMessage);
newImg.observe("mouseout", hideSignatureMessage);