Can't use HTTPS with ServerXMLHTTP object

后端 未结 5 442
生来不讨喜
生来不讨喜 2020-11-30 10:10

I am supporting a Classic ASP application that connects to a payment gateway via HTTPS. Up until recently there have been no issues. A few days ago the latest updates were

相关标签:
5条回答
  • 2020-11-30 10:54

    Can you try with oHttp.setOption(3) = "certificate store name/friendlyname of certificate" as below. I hope this will works.

    Dim oHttp                    
    Dim strResult 
    Set oHttp = CreateObject("MSXML2.ServerXMLHTTP")
    oHttp.setOption(2) = 13056
    oHttp.setOption(3) = "certificate store name/friendlyname of certificate"
    oHttp.open "POST", SOAP_ENDPOINT, false
    oHttp.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8"
    oHttp.setRequestHeader "SOAPAction", SOAP_NS + "/" & SOAP_FUNCTION
    oHttp.send SOAP_REQUEST
    
    0 讨论(0)
  • 2020-11-30 10:55

    This is probably a ServerFault.com question really, after all if the code is working fine then its not a programmatic problem.

    However I would try a couple of things. First try using a the ProgID "MSXML2.ServerXMLHTTP.3.0", in some circumstances MSXML3 will behave differently depending on which ProgID was used to instantiate the component. Also update from other sources like your anti-virus supplier (Sophos had this problem) can break MSXML installs.

    Another ProgID to try is "MSXML2.ServerXMLHTTP.6.0" after having installed MSXML6. If the problem is with an update to the MSXML3 core then perhaps the MSXML6 core doesn't have the same problem.

    0 讨论(0)
  • 2020-11-30 11:00

    Just found the solution to this which has passed testing on:

    • Windows 10 (IIS 10)
    • Windows 2012 R2 (IIS 8.5)

    It's a client problem. MSXML2.ServerXMLHTTP does indeed require you to use a client certificate when calling an endpoint secured with SSL (even if the endpoint doesn't require it), as the OP noted.

    On the webserver, you need to:

    1. Create a client certificate
    2. Assign permissions to the certificate
    3. Set the certificate on the ServerXMLHTTP object

    In detail:

    1. Create a client certificate

    Use the following PowerShell command to create a new self-signed certificate:

    New-SelfSignedCertificate -DnsName "ServerXMLHTTP", "ServerXMLHTTP" -CertStoreLocation "cert:\LocalMachine\My"
    

    Note that the certificate created by this command will only be valid for 1 year.

    2. Assign permissions to the certificate

    Using MMC, view the certificate store for the computer account: How to: View Certificates with the MMC Snap-in

    The certificate created above can be found in Certificates (Local Computer)\Personal\Certificates (the "Issued By" and "Issued To" columns display "ServerXMLHTTP").

    Right click the ServerXMLHTTP certificate, select "All Tasks" -> "Manage Private Keys" and the permissions dialog will display.

    Add the user that the ASP website app pool is running as. By default it will be running as "ApplicationPoolIdentity", but your setup may be using a specific user account. If the app pool is using ApplicationPoolIdentity, the username to add is "IIS AppPool\APP POOL NAME", e.g. IIS AppPool\DefaultAppPool

    The user will be added with "Full Control" which can be deselected. Only "Read" permission seems to be required. Click "OK" to confirm the permissions.

    3. Set the certificate on the ServerXMLHTTP object

    In your ASP code, set the ServerXMLHTTP object to use the certificate created above. For example calling PayPal for an access token:

    Dim strAuthToken: strAuthToken = "<Base64 encoded version of ClientId:Secret>"
    Dim oHttp: Set oHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
    
    With oHttp
        Call .Open("POST", "https://api.sandbox.paypal.com/v1/oauth2/token", False)
        Call .SetOption(3, "LOCAL_MACHINE\My\ServerXMLHTTP")
        Call .SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
        Call .SetRequestHeader("Authorization", "Basic " & strAuthToken)
        Call .Send("grant_type=client_credentials")
    End With
    

    Hopefully this is still of assistance.

    0 讨论(0)
  • 2020-11-30 11:03

    I know it is an old question. This issue could be because of unsupported cipher suites. Try adding - TLS_RSA_WITH_AES_128_CBC_SHA AES128-SHA - TLS_RSA_WITH_AES_256_CBC_SHA AES256-SHA

    That means you have to follow this kb: http://support.microsoft.com/kb/948963 This update is also interesting if you are still using windows 2003. Which will allow connecting to site using SHA2 - http://support.microsoft.com/kb/968730

    Please note that Windows Server 2003 support is ending July 14, 2015

    0 讨论(0)
  • 2020-11-30 11:04

    Try adding oHttp.setOption 2, 13056

    0 讨论(0)
提交回复
热议问题