Programming

You are currently browsing the articles from Information City matching the category Programming.

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

Was trying to develop a test app. that interfaces to webservice hosted under SSL but prompted error as stated in topic. There wasn’t any issue if the app. connects to function hosted by webservice without SSL. A further checking, the certificate used by the webservice has already expired (since the certificate was generated as test during initial setup) and no longer being updated. Thinking not to touch the web server on the SSL configuration, I thought I should come up with a workaround instead since normal web browser access works just fine even if the certificate is expired or invalid.

One workaround which I can find in Microsoft forum, to overwrites the handler function of when accepting certificate from the server through (ServicePointManager.ServerCertificateValidationCallback). A snippet of the code as below:

Private Function ValidateCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
‘Return True to force the certificate to be accepted.
Return True
End Function

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
End Sub

For more in-depth explanation, refer to Microsoft Support.

Keywords:

Written by admin on May 14th, 2012 with no comments.
Read more articles on Programming and Web.

VB.NET: How to determine if a file has been changed/updated

Been eager to know about this and found out this could possibly identify if file has changed since last reading date using System.IO namespace, by checking the file’s GetLastWriteTime and GetCreationTime. If either of these two is more recent that the last reading date, that could eventually means the file has been updates/modified. It’s worth taking note that CreationTime is not always less than LastWriteTime. If a file is overwritten, the new file retains the LastWriteTime of the source but the CreationTime will be the time where replacement took place.

Keywords:

Written by admin on April 4th, 2012 with no comments.
Read more articles on Programming and Web.

« Older articles

No newer articles