Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Programming / CLR / July 2009

Tip: Looking for answers? Try searching our database.

Could not establish trust relationship for the SSL/TLS secure channel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
calum.mitchell@gmail.com - 26 Apr 2009 13:34 GMT
I'm using SQL Server 2005 and trying to write a clr stored procedure
which uses the HttpWebRequest class to make an HTTPS request and
getting the following exception.

System.Net.WebException: The underlying connection was closed: Could
not establish trust relationship for the SSL/TLS secure channel. --->
System.Security.Authentication.AuthenticationException: The remote
certificate is invalid according to the validation procedure.<nl/>
at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken
message<c/> AsyncProtocolRequest asyncRequest<c/> Exception exception)
<nl/>   at
System.Net.Security.SslState.CheckCompletionBeforeNextReceive
(ProtocolToken message<c/> AsyncProtocolRequest asyncRequest)<nl/>
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming<c/>
Int32 count<c/> AsyncProtocolRequest asyncRequest)<nl/>   at
System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer<c/>
Int32 count<c/> AsyncProtocolRequest asyncRequest)<nl/>   at
System.Net.Security.SslState.StartReadFrame(Byte[] buffer<c/> Int32
readBytes<c/> AsyncProtocolRequest asyncRequest)<nl/>   at
System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer<c/>
AsyncProtocolRequest asyncRequest)<nl/>   at
System.Net.Security.SslState.CheckCompletionBeforeNextReceive
(ProtocolToken message<c/> AsyncProtocolRequest asyncRequest)<nl/>
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming<c/>
Int32 count<c/> AsyncProtocolRequest asyncRequest)<nl/>   at
System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer<c/>
Int32 count<c/> AsyncProtocolRequest asyncRequest)<nl/>   at
System.Net.Security.SslState.StartReadFrame(Byte[] buffer<c/> Int32
readBytes<c/> AsyncProtocolRequest asyncRequest)<nl/>   at
System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer<c/>
AsyncProtocolRequest asyncRequest)<nl/>   at
System.Net.Security.SslState.CheckCompletionBeforeNextReceive
(ProtocolToken message<c/> AsyncProtocolRequest asyncRequest)<nl/>
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming<c/>
Int32 count<c/> AsyncProtocolRequest asyncRequest)<nl/>   at
System.Net.Security.SslState.ProcessReceivedB...

This means the stored procedure could not authenticate the webserver's
SSL certificate.

I've found three ways of handling this situation in a regular C#
application, but couldn't get any of them work for a clr stored
procedure.

1. Setting System.Net.ServicePointManager.CertificatePolicy to a class
which implements System.Net.ICertificatePolicy.

2. Setting
System.Net.ServicePointManager.ServerCertificateValidationCallback to
a delegate which validates the server certification.

3. Importing the webserver's SSL certificate's CA certificate into the
Trusted Root Certificate Authorities of the current user.

1 and 2 are explicitly disallowed by SQL Server and 3 doesn't work.

I think the only option is to import the webserver's SSL certificate's
CA certificate into somewhere that SQL Server clr uses. So far I've
tried the Trusted Root Certificate Authorities section of the current
user, local machine and SQL Server service but none of them have
worked.

Does anyone know what I have to do to allow an HTTPS request to be
made by a clr stored procedure?

Thanks,
Calum
Dan Holmes - 27 Apr 2009 12:59 GMT
> I'm using SQL Server 2005 and trying to write a clr stored procedure
> which uses the HttpWebRequest class to make an HTTPS request and
[quoted text clipped - 63 lines]
> Thanks,
> Calum
Do you have permissions set to EXTERNAL_ACCESS?
calum.mitchell@gmail.com - 28 Apr 2009 22:56 GMT
> calum.mitch...@gmail.com wrote:
> > I'm using SQL Server 2005 and trying to write a clr stored procedure
[quoted text clipped - 66 lines]
>
> Do you have permissions set to EXTERNAL_ACCESS?

Yes and trustworthy is set on in the database.

Thanks,
Calum
Cube - 01 Jul 2009 17:34 GMT
Hi Calum,

Did you get anywhere with this in the end? I'm encountering the same problems?

> > calum.mitch...@gmail.com wrote:
> > > I'm using SQL Server 2005 and trying to write a clr stored procedure
[quoted text clipped - 71 lines]
> Thanks,
> Calum
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.