Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27201

VS 2010 Help with base64 decoding!

$
0
0
Hi!

Im currently working on a client that get information from a backend server (Linux/java). The server and client send smime messages between eachother, and for some reason, when the server sends a message containing a binary file, this file becomes bigger when it is decoded on the server.

The message looks something like this
Code:

Message-ID: <846550737.170.1360675318640.JavaMail.abc@bretssa>
MIME-Version: 1.0
Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-1;
        boundary="----=_Part_169_743690211.1360675318603"
X-Unencoded-Content-Length: 5836

------=_Part_169_743690211.1360675318603
Content-Type: application/pkcs-12
Content-Transfer-Encoding: base64

MIINFgIBAzCCDNAGCSqGSIb3DQEHAaCCDMEEggy9MIIMuTCCBW4GCSqGSIb3DQEHAaCCBV8EggVb
MIIFVzCCBVMGCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcNAQwBAzAaBBQnLESNpCKgUS9p
1AMuYcNbwHThOgICBAAEggTIVm3CqW3KltldgI0PCef0SsoHfUtQTr98LxlkwE3pP8ESplU4/C7m
hpqM/e1LaQlbzLwVGb/86NkZ3kSj+HNC0O+0Vy/h7MFRrosFZNSlJIJom8y6elTo3CPokT57vPIf
OCe0oPwsNcGUJiywNh888OlQNiIiUmXuL6qUpKyqmvBKt3qSF/7nXyxG8sJXsMUnc86aHguWLgWT
------=_Part_169_743690211.1360675318603
Content-Type: application/pkcs7-signature; name=smime.p7s; smime-type=signed-data
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAMYICGTCCAhUC
AQEwgZIwgYoxCzAJBgNVBAYTAlNFMTUwMwYDVQQKDCxXaXJlbGVzcyBJbmRlcGVuZGVudCBQcm92
------=_Part_169_743690211.1360675318603--

They have checked on the server and the binary file is about 2,5 kb Before they encode it to base64 and send it. And when I read the smime message, and use the Convert.FromBase64 and write the file as a byte Array to disk, it is about 3,5 kb in size! Where does the extra 1 kb come from?

I even did a test and used copy/paste and took only the base64 chunk that represent the file and pasted it into a text document, and did a Convert.FromBase64 and got the exact same file around 3,5 kb. This to rule out any bugs in the smime Component we use to parse mime messages.

What is wrong here? What have we forgotten? Are there additional characters that get embedded somehow, line breaks, CR etc? Or do we use different base64 on java server and .net client?

any ideas?
/H

Viewing all articles
Browse latest Browse all 27201

Trending Articles