EMonaco
2004-05-07 21:13:04 UTC
All,
Well, I'm confounded having just dealt with 3 serious issues concerning
WinINet and the 832894 security patch, (Took all of February!) and it looks
like I've run into another! I will try to simplify everything as much as
possible.
Have an app that goes to a servlet using HTTPS (wininet). This app first
does a GET request and then POST requests (sending data in 132 byte packets)
till done. We do a simple date check for server cert validity as well as the
server requiring a client cert.
Normal operation should be:
Open Request. Do GET, receive error that client cert is needed, find & set
client cert, do HttpSendRequest() again. Get Response. Check Response.
Validate server cert. Close Request handle.
Open Request. Set client cert obtained above. Send Request. Get Response.
Check Response. Close Request.
This continues until done or 5 minute timeout.
Each 132 byte request is an item lookup, items are entered by user in
realtime.
Scenerio 1: FAILS!
Open Request. Do GET, receive error client cert needed. find&set client
cert, do HttpSendRequest() again. Get Response. Check Response. Validate
server cert. Close Request handle.
Open Request. Set client cert obtained above. Send Request. Get Response.
Check Response. Close Request.
Wait over 30 seconds. (server closes socket)
Open Request. Set client cert obtained above. Send Request. Get Error
"HttpSendRequest() Error(0x2f7d): An error occurred in the secure channel
support".
Now if I do each lookup before the server closes the socket due to
inactivity, everything works as expected.
Observations: First socket is opened SSL negotiation starts- is closed,
SendRequest() returns with client cert needed.
When I set the client cert and submit request again, a new socket is opened,
and everything proceeds. Wininet now uses that same socket for subsequent
request (as long as its not closed) however if it is closed, wininet opens
and closes a socket, but the wininet log does not show it "Sending" any data
on the attempt. (mind you we are setting INTERNET_FLAG_KEEP_CONNECTION! So
on the face of it, it seems that WinInet can't deal with the socket being
closed. (that is can't open a new socket and resume or start a new SSL
session).
If your still with me, here is where things get REALLY weird. My app has the
ability to retrieve a dword from the registry that is OR'd with the
(INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_SECURE) flags on the
HttpOpenRequest. This is because I use a local IIS to test and its
certificate CN is by DNS name, but I use the IP address... hence I'll get an
INVALID_CN_NAME error if I don't include 0x1000
(INTERNET_FLAG_IGNORE_CERT_CN_INVALID) along with the HttpOpenRequest. Which
leads us to:
Scenario 2: Successful!
Do the same as scenario 1, only set the registry value for extra flags to
0x1000 (INTERNET_FLAG_IGNORE_CERT_CN_INVALID).
After 30 seconds, the server still closes the socket- but I don't get an
error and everything works. Investigation Wininet log and TDIMON dump- I see
a big difference, something about this flag- or the combination, causes
wininet to open a socket, do all the ssl handshake, server/client cert
exhange for every batch of HttpOpen/HttpSend Request!!!! I would think this
would be a function of only the INTERNET_FLAG_KEEP_CONNECTION, however I
removed it and get the same results- without the
INTERNET_FLAG_IGNORE_CERT_CN_INVALID, it reuses the same socket unless the
socket is disconnected by the remote at which point it fails- with the flag-
it uses a new socket for every request and does the whole SSL handshake cert
swap (which works fine- but adds a lot of extra data to the network).
So- just what the heck is goin on!? I'm sure this isn't right and whats it
gonna take to get it fixed!? PS now would be a good time to discuss finder
fees :)
Machine Info: Dell Inspiron 8200, 1.6Ghz, 512Meg. XP Pro, ALL critical
patches applied. (but this doesn't seem to matter, at least not entirely)
I've tried 3 debug versions of WinINet 6.0.2800.1106, 6.0.2800.1400, and
6.0.2800.1405 and I get the exact same results!
Erin.
Well, I'm confounded having just dealt with 3 serious issues concerning
WinINet and the 832894 security patch, (Took all of February!) and it looks
like I've run into another! I will try to simplify everything as much as
possible.
Have an app that goes to a servlet using HTTPS (wininet). This app first
does a GET request and then POST requests (sending data in 132 byte packets)
till done. We do a simple date check for server cert validity as well as the
server requiring a client cert.
Normal operation should be:
Open Request. Do GET, receive error that client cert is needed, find & set
client cert, do HttpSendRequest() again. Get Response. Check Response.
Validate server cert. Close Request handle.
Open Request. Set client cert obtained above. Send Request. Get Response.
Check Response. Close Request.
This continues until done or 5 minute timeout.
Each 132 byte request is an item lookup, items are entered by user in
realtime.
Scenerio 1: FAILS!
Open Request. Do GET, receive error client cert needed. find&set client
cert, do HttpSendRequest() again. Get Response. Check Response. Validate
server cert. Close Request handle.
Open Request. Set client cert obtained above. Send Request. Get Response.
Check Response. Close Request.
Wait over 30 seconds. (server closes socket)
Open Request. Set client cert obtained above. Send Request. Get Error
"HttpSendRequest() Error(0x2f7d): An error occurred in the secure channel
support".
Now if I do each lookup before the server closes the socket due to
inactivity, everything works as expected.
Observations: First socket is opened SSL negotiation starts- is closed,
SendRequest() returns with client cert needed.
When I set the client cert and submit request again, a new socket is opened,
and everything proceeds. Wininet now uses that same socket for subsequent
request (as long as its not closed) however if it is closed, wininet opens
and closes a socket, but the wininet log does not show it "Sending" any data
on the attempt. (mind you we are setting INTERNET_FLAG_KEEP_CONNECTION! So
on the face of it, it seems that WinInet can't deal with the socket being
closed. (that is can't open a new socket and resume or start a new SSL
session).
If your still with me, here is where things get REALLY weird. My app has the
ability to retrieve a dword from the registry that is OR'd with the
(INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_SECURE) flags on the
HttpOpenRequest. This is because I use a local IIS to test and its
certificate CN is by DNS name, but I use the IP address... hence I'll get an
INVALID_CN_NAME error if I don't include 0x1000
(INTERNET_FLAG_IGNORE_CERT_CN_INVALID) along with the HttpOpenRequest. Which
leads us to:
Scenario 2: Successful!
Do the same as scenario 1, only set the registry value for extra flags to
0x1000 (INTERNET_FLAG_IGNORE_CERT_CN_INVALID).
After 30 seconds, the server still closes the socket- but I don't get an
error and everything works. Investigation Wininet log and TDIMON dump- I see
a big difference, something about this flag- or the combination, causes
wininet to open a socket, do all the ssl handshake, server/client cert
exhange for every batch of HttpOpen/HttpSend Request!!!! I would think this
would be a function of only the INTERNET_FLAG_KEEP_CONNECTION, however I
removed it and get the same results- without the
INTERNET_FLAG_IGNORE_CERT_CN_INVALID, it reuses the same socket unless the
socket is disconnected by the remote at which point it fails- with the flag-
it uses a new socket for every request and does the whole SSL handshake cert
swap (which works fine- but adds a lot of extra data to the network).
So- just what the heck is goin on!? I'm sure this isn't right and whats it
gonna take to get it fixed!? PS now would be a good time to discuss finder
fees :)
Machine Info: Dell Inspiron 8200, 1.6Ghz, 512Meg. XP Pro, ALL critical
patches applied. (but this doesn't seem to matter, at least not entirely)
I've tried 3 debug versions of WinINet 6.0.2800.1106, 6.0.2800.1400, and
6.0.2800.1405 and I get the exact same results!
Erin.
--
Visit us on the web at: http://www.databasementsoftware.com
Visit us on the web at: http://www.databasementsoftware.com