Skip to content

Commit 542b845

Browse files
authored
Moved TLS 1.2 setting before HttpWebRequest
1 parent c1de04d commit 542b845

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Authorize.NET/Util/HttpUtility.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ public static ANetApiResponse PostData<TQ, TS>(AuthorizeNet.Environment env, TQ
3939
throw new ArgumentNullException("request");
4040
}
4141
//Logger.debug(string.Format("MerchantInfo->LoginId/TransactionKey: '{0}':'{1}'->{2}",
42-
//request.merchantAuthentication.name, request.merchantAuthentication.ItemElementName, request.merchantAuthentication.Item));
43-
44-
var postUrl = GetPostUrl(env);
42+
//request.merchantAuthentication.name, request.merchantAuthentication.ItemElementName, request.merchantAuthentication.Item));
43+
44+
// Set Tls to Tls1.2
45+
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
46+
47+
var postUrl = GetPostUrl(env);
4548
var webRequest = (HttpWebRequest) WebRequest.Create(postUrl);
4649
webRequest.Method = "POST";
4750
webRequest.ContentType = "text/xml";
@@ -67,9 +70,6 @@ public static ANetApiResponse PostData<TQ, TS>(AuthorizeNet.Environment env, TQ
6770
String responseAsString = null;
6871
Logger.debug(string.Format("Retreiving Response from Url: '{0}'", postUrl));
6972

70-
// Set Tls to Tls1.2
71-
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
72-
7373
using (var webResponse = webRequest.GetResponse())
7474
{
7575
Logger.debug(string.Format("Received Response: '{0}'", webResponse));

0 commit comments

Comments
 (0)