Authorize.net payment not working on 32bit Windows server 2008 machine while it is working fine on Windows Server 2012R2

Sudhanshum
Sudhanshum used Ask the Experts™
on
Hi I am using Authorize.net for payment gateway in my Asp.net code, It suddenly stopped working few days back, I want to fix that immediately, Please help me,
I am getting error on below line
myWriter = new StreamWriter(objRequest.GetRequestStream()
Error is The exception message is 'The request was aborted: Could not create SSL/TLS secure channel.'. See server logs for more details.
Here is code, My windows machine is Windows server 2008 and I have installed Framework 4.5.

    I tried to setup that on Windows server 2012 R2 and it is working fine there, Problem is in current Production machine which is 32bit machine, Is Authorized.net not compatible with 32 bit machine? Please let me know.

 
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
        String ApiLogin = System.Configuration.ConfigurationManager.AppSettings["ApiLoginL"];
        String TransactionKey = System.Configuration.ConfigurationManager.AppSettings["TransactionKeyL"];

    
        String post_url = "https://secure2.authorize.net/gateway/transact.dll";

        Dictionary<string, string> post_values = new Dictionary<string, string>();

        post_values.Add("x_login", ApiLogin);
        post_values.Add("x_tran_key", TransactionKey);
        post_values.Add("x_delim_data", "TRUE");
        post_values.Add("x_delim_char", "|");
        post_values.Add("x_relay_response", "FALSE");

        post_values.Add("x_type", "AUTH_CAPTURE");
        post_values.Add("x_method", "CC");
        post_values.Add("x_card_num", OrderD.CARDNUMBER);
   
        post_values.Add("x_card_code", OrderD.CVV);
       
        post_values.Add("x_exp_date", OrderD.MONTH + "" + OrderD.YEAR);

        post_values.Add("x_amount", "1");


        post_values.Add("x_description", "");

        StrSql = "SELECT USERID, FIRSTNAME,LASTNAME,COMPANYNAME,(STREETADDRESS1||' '||STREETADDRESS2)ADDRESS,STATE,ZIPCODE,CITY,COUNTRY FROM USERCONTACTS ";
        StrSql = StrSql + "WHERE USERID=  " + OrderD.USERID + "  ";
        dt = OdButil.FillDataTable(StrSql, MyConnectionString);


        post_values.Add("x_first_name", dt.Rows[0]["FIRSTNAME"].ToString());
        post_values.Add("x_last_name", dt.Rows[0]["LASTNAME"].ToString());
        post_values.Add("x_company", dt.Rows[0]["COMPANYNAME"].ToString());

        post_values.Add("x_address", dt.Rows[0]["ADDRESS"].ToString());
        post_values.Add("x_state", dt.Rows[0]["STATE"].ToString());
        post_values.Add("x_zip", dt.Rows[0]["ZIPCODE"].ToString());
        post_values.Add("x_city", dt.Rows[0]["CITY"].ToString());
        post_values.Add("x_country", dt.Rows[0]["COUNTRY"].ToString());

        String post_string = "";/* TODO ERROR: Skipped SkippedTokensTrivia */

        foreach (KeyValuePair<string, string> post_value in post_values)/* TODO ERROR: Skipped SkippedTokensTrivia */
            post_string += post_value.Key + "=" + HttpUtility.UrlEncode(post_value.Value) + "&";/* TODO ERROR: Skipped SkippedTokensTrivia */
        post_string = post_string.TrimEnd('&');/* TODO ERROR: Skipped SkippedTokensTrivia */

        //Create an HttpWebRequest object to communicate with Authorize.net
        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(post_url);/* TODO ERROR: Skipped SkippedTokensTrivia */
        objRequest.Method = "POST";
        objRequest.ContentLength = post_string.Length;
        objRequest.ContentType = post_url;

        //post data is sent as a stream
        StreamWriter myWriter = null;/* TODO ERROR: Skipped SkippedTokensTrivia */
        myWriter = new StreamWriter(objRequest.GetRequestStream());/* TODO ERROR: Skipped SkippedTokensTrivia */
        myWriter.Write(post_string);
        myWriter.Close();

        //returned values are returned as a stream, then read into a string
        String post_response;
        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
        using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()))
        {
            post_response = responseStream.ReadToEnd();
            responseStream.Close();
        }

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
The bit level of the server isn't going to impact TLS.  Most likely you need to enable TLS 1.2 on your production server.

https://support.microsoft.com/en-us/help/3140245/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-wi

You can also use IIS Crypto if you would prefer not to dig around in the registry:

https://www.nartac.com/Products/IISCrypto/

I also had to expand the Tls options to make it work for one vendor:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

Open in new window

-saige-
Top Expert 2016

Commented:
You need to add the recommended update https://www.microsoft.com/security/blog/2017/07/20/tls-1-2-support-added-to-windows-server-2008/ AND set the registry keys to allow TLS 1.1 and 1.2
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1
Key Enabled DWORD 1
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1 Key Enabled DWORD 1

Open in new window

Author

Commented:
I updated windows to latest version, Even I tried to install windows update from Microsoft Update Catalog
 but it did not worked there, I have added TLS 1.2 entry but it did not worked out, Please see attached image

Author

Commented:
I checked my site on https://entrust.ssllabs.com/index.html and found that TLS 1.2 is already active, Dont know what is actual issue.

Author

Commented:
I added event log and here is it logged:

System.Net Information: 0 : [3444] SecureChannel#49056616::.ctor(hostname=secure2.authorize.net, #clientCertificates=0, encryptionPolicy=RequireEncryption)
System.Net Information: 0 : [3444] Enumerating security packages:
System.Net Information: 0 : [3444]     Negotiate
System.Net Information: 0 : [3444]     Kerberos
System.Net Information: 0 : [3444]     NTLM
System.Net Information: 0 : [3444]     Schannel
System.Net Information: 0 : [3444]     Microsoft Unified Security Protocol Provider
System.Net Information: 0 : [3444]     WDigest
System.Net Information: 0 : [3444]     TSSSP
System.Net Information: 0 : [3444]     CREDSSP
System.Net Information: 0 : [3444] SecureChannel#49056616 - Left with 0 client certificates to choose from.
System.Net Information: 0 : [3444] SecureChannel#49056616::.AcquireClientCredentials, new SecureCredential() (flags=(ValidateManual, NoDefaultCred, SendAuxRecord), m_ProtocolFlags=(Tls12Client), m_EncryptionPolicy=RequireEncryption)
System.Net Information: 0 : [3444] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)
System.Net Information: 0 : [3444] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = secure2.authorize.net, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [3444] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=155, returned code=ContinueNeeded).
System.Net.Sockets Verbose: 0 : [3444] Entering Socket#22584602::Send()
System.Net.Sockets Verbose: 0 : [3444] Data from Socket#22584602::Send
System.Net.Sockets Verbose: 0 : [3444] 00000000 : 16 03 03 00 96 01 00 00-92 03 03 5C B8 BC A6 4D : ...........\...M
System.Net.Sockets Verbose: 0 : [3444] 00000010 : 5E 5C 17 4E 74 AC C6 A6-3B E2 E8 36 31 2E A9 E3 : ^\.Nt...;..61...
System.Net.Sockets Verbose: 0 : [3444] 00000020 : 50 A5 0E 63 03 13 D9 2A-29 7A 8B 00 00 18 00 2F : P..c...*)z...../
System.Net.Sockets Verbose: 0 : [3444] 00000030 : 00 35 00 05 00 0A C0 09-C0 0A C0 13 C0 14 00 32 : .5.............2
System.Net.Sockets Verbose: 0 : [3444] 00000040 : 00 38 00 13 00 04 01 00-00 51 00 00 00 1A 00 18 : .8.......Q......
System.Net.Sockets Verbose: 0 : [3444] 00000050 : 00 00 15 73 65 63 75 72-65 32 2E 61 75 74 68 6F : ...secure2.autho
System.Net.Sockets Verbose: 0 : [3444] 00000060 : 72 69 7A 65 2E 6E 65 74-00 0A 00 08 00 06 00 17 : rize.net........
System.Net.Sockets Verbose: 0 : [3444] 00000070 : 00 18 00 19 00 0B 00 02-01 00 00 0D 00 14 00 12 : ................
System.Net.Sockets Verbose: 0 : [3444] 00000080 : 04 01 05 01 02 01 04 03-05 03 02 03 02 02 06 01 : ................
System.Net.Sockets Verbose: 0 : [3444] 00000090 : 06 03 00 17 00 00 FF 01-00 01 00                : ...........
System.Net.Sockets Verbose: 0 : [3444] Exiting Socket#22584602::Send()       -> Int32#155
System.Net.Sockets Verbose: 0 : [3444] Entering Socket#22584602::Receive()
System.Net.Sockets Verbose: 0 : [3444] Data from Socket#22584602::Receive
System.Net.Sockets Verbose: 0 : [3444] 00000000 : 15 03 03 00 02                                  : .....
System.Net.Sockets Verbose: 0 : [3444] Exiting Socket#22584602::Receive()       -> Int32#5
System.Net.Sockets Verbose: 0 : [3444] Entering Socket#22584602::Receive()
System.Net.Sockets Verbose: 0 : [3444] Data from Socket#22584602::Receive
System.Net.Sockets Verbose: 0 : [3444] 00000005 : 02 28                                           : .(
System.Net.Sockets Verbose: 0 : [3444] Exiting Socket#22584602::Receive()       -> Int32#2
System.Net Information: 0 : [3444] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = 1b752b40:1a97538, targetName = secure2.authorize.net, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [3444] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=IllegalMessage).
System.Net.Sockets Verbose: 0 : [3444] Entering Socket#22584602::Dispose()
System.Net Error: 0 : [3444] Exception in HttpWebRequest#40452378:: - The request was aborted: Could not create SSL/TLS secure channel..
System.Net Error: 0 : [3444] Exception in HttpWebRequest#40452378::EndGetRequestStream - The request was aborted: Could not create SSL/TLS secure channel..
System.Net Information: 0 : [4048] ServicePoint#53681453 - Closed as idle.
System.Net Verbose: 0 : [4048] Entering SmtpPooledStream::Dispose #31097735
System.Net.Sockets Verbose: 0 : [4048] Entering Socket#51201079::Send()
System.Net.Sockets Verbose: 0 : [4048] Data from Socket#51201079::Send
System.Net.Sockets Verbose: 0 : [4048] 00000000 : 51 55 49 54 0D 0A                               : QUIT..
System.Net.Sockets Verbose: 0 : [4048] Exiting Socket#51201079::Send()       -> Int32#6
System.Net.Sockets Verbose: 0 : [4048] Entering Socket#51201079::Receive()
System.Net.Sockets Verbose: 0 : [4048] Data from Socket#51201079::Receive
System.Net.Sockets Verbose: 0 : [4048] 00000000 : 32 32 31 20 32 2E 30 2E-30 20 73 6D 62 69 6D 70 : 221 2.0.0 smbimp
System.Net.Sockets Verbose: 0 : [4048] 00000010 : 6F 75 74 30 30 36 2E 6D-73 67 2E 63 68 72 6C 2E : out006.msg.chrl.
System.Net.Sockets Verbose: 0 : [4048] 00000020 : 6E 63 2E 63 68 61 72 74-65 72 2E 6E 65 74 20 63 : nc.charter.net c
System.Net.Sockets Verbose: 0 : [4048] 00000030 : 6D 73 6D 74 70 20 63 6C-6F 73 69 6E 67 20 63 6F : msmtp closing co
System.Net.Sockets Verbose: 0 : [4048] 00000040 : 6E 6E 65 63 74 69 6F 6E-0D 0A                   : nnection..
System.Net.Sockets Verbose: 0 : [4048] Exiting Socket#51201079::Receive()       -> Int32#74
System.Net.Sockets Verbose: 0 : [4048] Entering Socket#51201079::Dispose()
System.Net Verbose: 0 : [4048] Exiting SmtpPooledStream::Dispose #31097735

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial