Index: camel/camel-gpg-context.c
===================================================================
--- camel/camel-gpg-context.c	(revision 10039)
+++ camel/camel-gpg-context.c	(working copy)
@@ -1434,9 +1434,11 @@ gpg_verify (CamelCipherContext *context,
 	char *sigfile = NULL;
 	CamelContentType *ct;
 	CamelMimePart *sigpart;
-	CamelStream *istream = NULL;
+	CamelStream *istream = NULL, *canon_stream;
 	CamelMultipart *mps;
-	
+	CamelStreamFilter *filter;
+	CamelMimeFilter *canon;
+
 	mps = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)ipart);
 	ct = ((CamelDataWrapper *)mps)->mime_type;
 	
@@ -1523,11 +1525,26 @@ gpg_verify (CamelCipherContext *context,
 	}
 	
 	camel_stream_reset(istream);
+	canon_stream = camel_stream_mem_new ();
+
+	/* strip trailing white-spaces */
+	filter = camel_stream_filter_new_with_stream (canon_stream);
+	canon = camel_mime_filter_canon_new (CAMEL_MIME_FILTER_CANON_CRLF | CAMEL_MIME_FILTER_CANON_STRIP);
+	camel_stream_filter_add (filter, canon);
+	camel_object_unref (canon);
+
+	camel_stream_write_to_stream (istream, (CamelStream *)filter);
+
+	camel_object_unref (filter);
+	camel_stream_reset (istream);
+
+	camel_stream_reset (canon_stream);
+
 	gpg = gpg_ctx_new (context->session);
 	gpg_ctx_set_mode (gpg, GPG_CTX_MODE_VERIFY);
 	if (sigfile)
                 gpg_ctx_set_sigfile (gpg, sigfile);
-	gpg_ctx_set_istream (gpg, istream);
+	gpg_ctx_set_istream (gpg, canon_stream);
 	
 	if (gpg_ctx_op_start (gpg) == -1) {
 		camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -1564,6 +1581,7 @@ gpg_verify (CamelCipherContext *context,
 		g_free (sigfile);
 	}
 	camel_object_unref(istream);
+	camel_object_unref (canon_stream);
 	
 	return validity;
 	
Index: camel/ChangeLog
===================================================================
--- camel/ChangeLog	(revision 10039)
+++ camel/ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2009-02-09  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #571046
+
+	* camel-gpg-context.c: (gpg_verify):
+	Always strip trailing white-spaces added during message transmission,
+	before verifying message signature.
+
 2009-02-02  Srinivasa Ragavan  <sragavan@novell.com>
 
 	* camel-db.c: (camel_db_migrate_folder_prepare), (cdb_delete_ids):
