SSL decryption problem (client side)
Hi everyone,
I am in a phase of implementing SMTP protocol in my application. All is good until after a sequence of messages are exchanged successfully, at the same particular message, DecryptMessage gives me 0x8009030F (i.e. SEC_E_MESSAGE_ALTERED). I do not know why this is happening. The message is never altered. Also, this happens only with one mail server.
I am using VC++ 6.0
Any help will be highly appreciated.
Regards.
Re: SSL decryption problem (client side)
I am not sure exactly when you are getting this error.
I was stuggling with this exact thing a few years back. From what I remember.... I coded the ssl handshake without using a third part lib so I used schannel. Typically during the intiial handshake the server has nothing to say after the handshake is complete. The client 'speaks' first. In my case the server would always speak first. Most times it was fine because the handshake would complete and then doing a peek/read I would get the first chunk of application data to try and decrypt. Once in a while some of that app data would get bundled in with the tail end of the handshake. I needed to 'push' that data into my receive buffer and then do a read on the socket for more data. I coded it so that the read on the socket would check to see if there is data in the buffer. If so it would try to decrypt tthat data. If the packet was complete it would successfully decrypt and I would have the data just like I had actually done a Read on the socket. Before I did this the data that was bundled in with the handshake would fall on the floor. Doing another read would mean I was out of sequence and I would get the
SEC_E_MESSAGE_ALTERED error. So it seems to me that loosing a packet (or in my case maybe a piece of the packet) would result in this error instead of a sequence error. I am not sure if this is your issue but I know this scenario will definitely cause it to occur.
Hope this helps,
Bob