Reply
Highlighted
Member
Posts: 4
Registered: ‎09-08-2011

ARB Subscription Request SSL Connection Error

Hi,

 

I'm using ASP.NET C# to connect to the live ARB server:

 

https://api.authorize.net/xml/v1/request.api

 

When I make a Subscription Request from our live server, I get this error:

 

"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."

 

Now, the code works perfectly to either the live or test server from our development environment, but not from our production environment.  Authorize.NET live support (who was superbly unhelpful) told me it was a problem with OUR SSL certificate, which I don't buy.  Nothing else we do securely, even connections to non-ARB Authorize.NET API requests) has any issue at all.

 

The basic C# code for sending the requests is:

 

private XmlDocument SendRequest()       

{

            Uri myUri = new Uri(this._postUrl);
            HttpWebRequest req = WebRequest.Create(myUri) as HttpWebRequest;           

            req.KeepAlive = false;

            req.Method = "POST"; 

            req.ContentType = "text/xml";
           

            StreamWriter sw = new StreamWriter(req.GetRequestStream());            sw.WriteLine(this._doc.InnerXml);                           sw.Close();
           

            // Send the data

            WebResponse rsp = req.GetResponse();
 

            // Read the response

            StreamReader sr = new StreamReader(rsp.GetResponseStream());

            string content = sr.ReadToEnd();

 

            XmlDocument response = new XmlDocument();

            response.LoadXml(content);

 

            // Close the response and free resources

 

            sr.Close();

            rsp.Close();

 

            return response;

}

 

The exception is throw at WebResponse rsp = req.GetResponse();

 

Has anyone else seen this and have a solution for me?  Again, this doesn't happen when I call the regular Authorize.NET API at https://secure.authorize.net/gateway/transact.dll with the same credentials and the ARB system works perfectly in our development environment against both TEST and LIVE servers.

 

Thanks in advance!

 

Regards,

Bill Rowell

http://www.frightcatalog.com/

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: ARB Subscription Request SSL Connection Error

What do you get when you put https://api.authorize.net/xml/v1/request.api in the browser URL address on your production server/environment?

Member
Posts: 4
Registered: ‎09-08-2011

Re: ARB Subscription Request SSL Connection Error

I get:

 

This XML file does not appear to have any style information associated with it. The document tree is shown below.      <ErrorResponse><messages><resultCode>Error</resultCode><message><code>E00002</code><text>The content-type specified is not supported.</text></message></messages></ErrorResponse>

 

The request works and the site/page is secure.

 

-Bill

Member
Posts: 4
Registered: ‎09-08-2011

Re: ARB Subscription Request SSL Connection Error

We just updated our SSL certificate for this site/server the other day.  Our other secure pages are working fine though, so that's why I don't think our SSL certificate is the issue.

 

Could I be wrong?

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: ARB Subscription Request SSL Connection Error

[ Edited ]

Is that from Firefox?

 

This XML file does not appear to have any style information associated with it. The document tree is shown below.      <ErrorResponse><messages><resultCode>Error</result

Code><message><code>E00002</code><text>The content-type specified is not supported.</text></message></messages></ErrorResponse>

What about in IE?

 

I don't think is your SSL. It something about the production authorize.net SSL certificate your production server didn't like, or it caching an old/invalid certificate.

There is workaround http://dobrzanski.net/2009/04/01/systemnetwebexception-the-underlying-connection-was-closed-could-no...

Member
Posts: 4
Registered: ‎09-08-2011

Re: ARB Subscription Request SSL Connection Error

I'm almost positive that this is a problem with Authorize.NET's certificate I think and the way the .NET framework handles SSL certificates.  I found a work around here:

 

http://www.west-wind.com/weblog/posts/2007/Dec/12/Accepting-invalid-Certificates-for-WCFWeb-Services...

 

I used this line of code to ignore the error:

 

ServicePointManager.ServerCertificateValidationCallback +=

                 delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };

 

I think its because the name on the certificate doesn't exactly match the server I'm connecting to.  At least that's the best information I can find regarding this issue.

 

I have it working for now, but I'm not 100% thrilled with the solution.

 

-Bill