I'm having a problem using the xml request and send on an https Website.

Well i'm using this code:
vb.net Code:
  1. Private StrCertMsg As String
  2.     Protected Function OnCertificateValidation(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
  3.         StrCertMsg = "Server Certificate Issued To: " + certificate.Subject
  4.         StrCertMsg = StrCertMsg + "Server Certificate Issued By: " + certificate.Issuer
  5.         If Not (sslPolicyErrors) = sslPolicyErrors.None Then
  6.             Return False
  7.         Else
  8.             Return True
  9.         End If
  10.     End Function
  11. Public objRequest As HttpWebRequest
  12.     Public Function get_lic(ByVal str As String) As System.Xml.XmlDocument
  13.         Dim URL_BASE As String = "https://xml.website.com/xmlcenter/xmlquery.php"
  14.         Dim xmlDoc As System.Xml.XmlDocument
  15.         xmlDoc = New System.Xml.XmlDocument
  16.         Dim result As String = ""
  17.         Dim myWriter As StreamWriter
  18.         Dim sXML = "<?xml version='1.0' encoding='UTF-8' ?><xmlcenter><auth><username>abcd</username><password>abcd123</password></auth>" & _
  19.         "<xxxxx>" & _
  20.         "<asse code=""" & str & """>" & _
  21.         "</asse>" & _
  22.         "</xxxx></xmlcenter>"
  23.         ServicePointManager.CertificatePolicy = New MyCertificateValidation
  24.         objRequest = WebRequest.Create(URL_BASE)
  25.         objRequest.Method = "POST"
  26.         Try
  27.             myWriter = New StreamWriter(objRequest.GetRequestStream())
  28.             myWriter.Write(sXML)
  29.             myWriter.Flush()
  30.             myWriter.Close()
  31.         Catch e1 As Exception
  32.             Response.Write(e1.Message)
  33.         Finally
  34.         End Try
  35.         Dim objResponse As HttpWebResponse = objRequest.GetResponse()
  36.         Dim sr As StreamReader
  37.         sr = New StreamReader(objResponse.GetResponseStream())
  38.         result = sr.ReadToEnd()
  39.         sr.Close()
  40.         xmlDoc.LoadXml(result)
  41.         Return xmlDoc
  42.     End Function

And i'm using this to:
vb.net Code:
  1. Imports System.Security.Cryptography.X509Certificates
  2. Public Class MyCertificateValidation
  3.     Implements System.Net.ICertificatePolicy
  4.     Public Function CheckValidationResult(ByVal srvPoint As ServicePoint, _
  5.     ByVal cert As X509Certificate, ByVal request As WebRequest, ByVal problem As Integer) _
  6.        As Boolean Implements ICertificatePolicy.CheckValidationResult
  7.         Return True ' Accept all certificates
  8.     End Function
  9. End Class
  10. Public Class RequestState
  11.     Public request As WebRequest = Nothing
  12.     Public requestDocument As String
  13. End Class

This works. . . but sometimes it gives me a strange error. :| Is there anyway to do this without any marge to mistakes?