HttpSendRequest() call returns ERROR_INTERNET_CONNECTION_RESET (12031) RRS feed

  • Question

  • Hi

    I am writing code using WinINet for Windows Mobile 6.1.  But it returns 12031 error when I try to connect to HTTPS.  Following are settings and flags for my code.

    -   for InternetOpen(), I am using INTERNET_FLAG_ASYNC.

    - for HttpOpenRequest(), I am using

                        INTERNET_FLAG_KEEP_CONNECTION |
                        INTERNET_FLAG_PRAGMA_NOCACHE |
                        INTERNET_FLAG_SECURE |
                        INTERNET_FLAG_IGNORE_CERT_CN_INVALID |

    - If ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED, then I get PCCERT_CONTEXT from the Windows CertStore ("MY") then

    InternetSetOption(hReq, INTERNET_OPTION_CLIENT_CERT_CONTEXT, (LPVOID)pContext2, sizeof(CERT_CONTEXT));

    - if ERROR_INTERNET_INVALID_CA, I do following in my code

               InternetQueryOption (hReq, INTERNET_OPTION_SECURITY_FLAGS, (LPVOID)&flags, &flaglen);

                        flags |= SECURITY_FLAG_IGNORE_REVOCATION |
                                                     SECURITY_FLAG_IGNORE_UNKNOWN_CA |
                                                     SECURITY_FLAG_IGNORE_CERT_CN_INVALID |
                                                     SECURITY_FLAG_IGNORE_CERT_DATE_INVALID |

                        InternetSetOption (hReq, INTERNET_OPTION_SECURITY_FLAGS, &flags, sizeof(flags));

    My exact code works on laptop environment but it doesn't work on Windows Mobile device.

    And this is what I observed for each HttpSendRequest() call.

    (1) First HttpSendRequest() call, ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED is returns.  (My code handle as described above - InternetSetOption(hReq, INTERNET_OPTION_CLIENT_CERT_CONTEXT, (LPVOID)pContext2, sizeof(CERT_CONTEXT));)

    (2) Second HttpSendRequest() call, device prompts me to enter PIN for the cert.  I provide the correct PIN.

    (3) this should then return ERROR_INTERNET_INVALID_CA (in my laptop environment) but in mobile device, I get ERROR_INTERNET_CONNECTION_RESET.  I even modified the code to make more HttpSendRequest() calls but it keeps returning same ERROR_INTERNET_CONNECTION_RESET error.

    I can't find any clue or help on the web!

    Thanks in advance.

    Thursday, March 29, 2012 4:41 AM

All replies

  • You may have some connect problem in network.


    Friday, March 30, 2012 8:44 AM
  • Thanks for sharing your thought.  But based on my further testing, I found out that normal SSL connection (one way) works.  But when I start providing client cert (two way) I get ERROR_INTERNET_CONNECTION_RESET and never gets ERROR_INTERNET_INVALID_CA.  Is there a protocol or secure channel setting that I need to do in Windows mobiles?

    Thank you

    Sunday, April 1, 2012 2:07 AM