locked
Unable to use FTPWebRequest over SSL RRS feed

Answers

  • There us no FtpWebRequest.Security property. The other forums mentioned in this thread may be reffering to a third-party wrapper around FtpWebRequest or a totally different class.

     

    There are no changes in FtpWebRequest for Orcas. It does not support implicit SSL only explicit.

     

    Mariya

    Thursday, November 29, 2007 4:41 PM
    Moderator
  • Actually, .NET 2.0 does not currently support implicit SSL, only explicit.  We will consider adding this for a future release.
    Tuesday, December 6, 2005 10:35 PM
    Moderator

All replies

  • Just realized that the link works only for local installation of MSDN. Another link is

    http://msdn2.microsoft.com/en-us/library/system.net.ftpwebrequest.enablessl

     

    Any pointers, tips or guidance on how to use the new .NET classes to connect to a FTP server using SSL will be greatly appreciated.

     

    Thanks
    Friday, November 11, 2005 4:48 AM
  • The exception you are getting means the server returned data that does not conform to the FTP specification.  Can you post the stack trace and inner exception from the web exception as well as a network trace?

    You can get a network trace using the System.Net logging that is in version 2.0 of the Framework.  You can find instructions on how to do that here: http://blogs.msdn.com/dgorti/archive/2005/09/18/471003.aspx
    Friday, November 11, 2005 6:30 AM
  • Hi Mike

     

    The stack trace is

    System.Net.WebException: The underlying connection was closed: The server committed a protocol violation.

       at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)

       at System.Net.FtpWebRequest.RequestCallback(Object obj)

       at System.Net.CommandStream.Abort(Exception e)

       at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)

       at System.Net.FtpWebRequest.GetResponse()

       at FTP.SimpleFTPClient.Download(String destinationFile, Uri downloadUri) in C:\ABCD\SimpleFTPClient.vb:line 33"

     

    The InnerException is "Nothing"

    The network trace is

    System.Net Verbose: 0 : [3676] WebRequest::Create(ftp://os232.abcd.com:990/test.txt)

    System.Net Information: 0 : [3676] FtpWebRequest#50727427::.ctor(ftp://os232.abcd.com:990/test.txt)

    System.Net Verbose: 0 : [3676] Exiting WebRequest::Create()   -> FtpWebRequest#50727427

    System.Net Verbose: 0 : [3676] FtpWebRequest#50727427::GetResponse()

    System.Net Information: 0 : [3676] FtpWebRequest#50727427::GetResponse(Method=NLST.)

    System.Net.Sockets Verbose: 0 : [3676] Socket#36205315::Socket(InterNetwork#2)

    System.Net.Sockets Verbose: 0 : [3676] Exiting Socket#36205315::Socket()

    System.Net.Sockets Verbose: 0 : [3676] Socket#36205315::Connect(232:990#-395901540)

    System.Net.Sockets Verbose: 0 : [3676] Exiting Socket#36205315::Connect()

    System.Net Information: 0 : [3676] Associating FtpWebRequest#50727427 with FtpControlStream#18626439

    System.Net.Sockets Verbose: 0 : [3676] Socket#36205315::Receive()

    System.Net.Sockets Verbose: 0 : [3676] Data from Socket#36205315::Receive

    System.Net.Sockets Verbose: 0 : [3676] 00000000 :                                                 :

    System.Net.Sockets Verbose: 0 : [3676] Exiting Socket#36205315::Receive() -> 0#0

    System.Net.Sockets Verbose: 0 : [3676] Socket#36205315::Dispose()

    System.Net Information: 0 : [3676] FtpWebRequest#50727427::(Releasing FTP connection#18626439.)

    System.Net Error: 0 : [3676] Exception in the FtpWebRequest#50727427::GetResponse - The underlying connection was closed: The server committed a protocol violation.

    System.Net Error: 0 : [3676]    at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)

       at System.Net.FtpWebRequest.RequestCallback(Object obj)

       at System.Net.CommandStream.Abort(Exception e)

       at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)

       at System.Net.FtpWebRequest.GetResponse()

    System.Net Verbose: 0 : [3676] Exiting FtpWebRequest#50727427::GetResponse()

     

     

    I did some more reading and found out that the server I am using supports only implicit connections. Does the FTPWebRequest class utilize the implicit or explicit connections for FTP using SSL? Is there a way to connect to the server using implicit connection?

     

    Thanks

    Friday, November 11, 2005 4:17 PM
  • Your FTP Server as you suggested using implicit SSL COnnections. I believe the FTP requests are expeting the server to request the SSL Connection. Could you
    post a network trace of the connection?
    What is happening here is that the server closed the connection expecting that the client would do SSL but client is not doing SSL
    Friday, November 11, 2005 4:45 PM
    Moderator
  • Pardon my ignorance, but how do I get the network trace of the connection? I followed the link sent by Mike (linking to a blog) to create a network trace and I have posted that in my earlier post above.

     

    Thanks

    Friday, November 11, 2005 5:38 PM
  • Sid,

    Did you ever get this resolved?  I'm having the same issue.
    Monday, December 5, 2005 9:53 PM
  • No….I could not get it resolved. So we decided to go with a third party utility for using FTP over SSL.

    Monday, December 5, 2005 10:02 PM
  • Eeesh.  I was hoping to avoid that.  I'll keep plugging away and if I come up with anything, I'll let you know.
    Monday, December 5, 2005 10:54 PM
  • There is really no need to use a third party FTP support. .NET 2.0 fully supports SSL. The exception you are getting can be easily resolved if you know what the server is sending. Could one of you send me a repro>
    Tuesday, December 6, 2005 4:37 PM
    Moderator
  • Actually, .NET 2.0 does not currently support implicit SSL, only explicit.  We will consider adding this for a future release.
    Tuesday, December 6, 2005 10:35 PM
    Moderator
  • Hi,

    I got an exception saying "SSL cannot be enabled when using a proxy".

    What should I do?

    Please advise.

    Thanks,

    Lan

    Wednesday, April 12, 2006 6:21 PM
  • Would this explicit/implicit problem have anything to do with my active/passive async problem found here?:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=345847&SiteID=1

     

    TIA, lushdog

    Wednesday, April 12, 2006 11:37 PM
  • Sorry about posting a question in this thread. The question I had is related to is how to set ftp over explicit SSL with the FtpWebRequest class?

    I had seen some notes on other forums:

    Comment from TheLearnedOne
    Date: 01/13/2006 07:31AM PST

    Comment
    Aaah, here is what that means:

    FtpWebRequest.Security = FtpSecurity.Explicit;

    Bob

    But I do not see any property called Security for a FtpWebRequest object. Any pointers will be great.
    Monday, July 10, 2006 4:52 PM
  • Hi JonCole,

     

    I saw your earlier posting regarding the lack of support for implict SSL in FTPS with the 2.0 version of the .Net framework. I'm currently using the 2.0 framework together with 3.0 ( for Workflow support) and our customer mandates the use of implicit SSL.  So, my question then is has there been any support added since your last posting - or patches etc that I can now use. Or is there any other "workaround" that you could suggest.

     

    Thanks,

     

    Sid

     

    Wednesday, November 14, 2007 9:56 PM
  • There us no FtpWebRequest.Security property. The other forums mentioned in this thread may be reffering to a third-party wrapper around FtpWebRequest or a totally different class.

     

    There are no changes in FtpWebRequest for Orcas. It does not support implicit SSL only explicit.

     

    Mariya

    Thursday, November 29, 2007 4:41 PM
    Moderator
  • Hi

     

    I have been trying to connect to a FTP server using SSL. I have followed the example on MSDN -
    ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref10/html/P_System_Net_FtpWebRequest_EnableSsl.htm


    However I keep getting an exceptions when then “request.GetResponse” method is called. The exceptions is “WebException” and message is “The underlying connection was closed: The server committed a protocol violation”

     

    Does anybody have any working example to connect to a FTP server over SSL?

    Thanks for your help.

    See this free FTP tool on codeproject.
    Friday, July 2, 2010 3:05 PM
  • I downloaded the free FTP tool from codeproject, and I don't find where it supports SSL, only ordinary FTP.

    Does anybody have a working example of code that connects to an FTP server using SSL?

    Thanks for your help.

    Friday, September 3, 2010 6:30 PM
  • This is absolutely the best answer for anyone trying to use FTPWebRequest over SSL.

    I was recently tasked with implementing an unattended C# program that we can schedule to do secure (SSL) FTP uploads of multiple files concurrently and asynchronously, and to leverage all Microsoft products/platforms. In researching I found many examples of uploading a single file using FTPWebRequest. However in the practical world, the need is at least 99% of the time to FTP multiple files. I posted to forums and e-mailed Moderators "The SME's", asking for pointers to working sample code using FTPWebRequest, uploading multiple files using SSL, and have received no response to date.

    As we all know in the practical world the job has got to get done.

    Fortunately for me, I suggested Rebex and my boss approved the purchase, I implemented FTP based on requirement, and I moved on.

    I am sure however, that in time a moderator, or someone else, or even Microsoft will eventually post working sample code for uploading of multiple files concurrently and asynchronously using FTPWebRequest over SSL  -more in line with what real world requirements are.

    So if you are stuck with -using Microsoft platform, delivering solution, and then getting on with the next task, then don't spend all this time trying to figure out MS stuff that has none to little meaningful support documents. Use 3party, get the job done, move on, then in spare time play with this stuff.

    Monday, September 13, 2010 2:34 AM
  • this class is a recopilation from varios web sites, this code work's for me,

    Imports System.Collections.Generic
    Imports System.Text
    Imports System.Net
    Imports System.IO
    Imports System.Security.Cryptography.X509Certificates
    Imports System.Net.Security

    Namespace FtpSSLProxy
        Public Class FTP
            Public UserName As String = ""
            Public Password As String = ""
            Public KeepAlive As Boolean = False
            Public UseSSL As Boolean = True
            Public UserNamePxy As String = ""
            Public PasswordPxy As String = ""
            Public UsePxy As Boolean = False
            Public ProxyHost As String = ""
            Public ProxyPort As Integer = 80
            Private m_FTPSite As String = ""

            Public Property FTPSite() As String
                Get
                    Return m_FTPSite
                End Get
                Set(ByVal value As String)
                    m_FTPSite = "ftp://" & value
                    If Not m_FTPSite.EndsWith("/") Then
                        m_FTPSite += "/"
                    End If
                End Set
            End Property
            Private m_CurDir As String = ""
            Public Property CurrentDirectory() As String
                Get
                    Return m_CurDir
                End Get
                Set(ByVal value As String)
                    m_CurDir = value
                    If Not m_CurDir.EndsWith("/") AndAlso m_CurDir <> "" Then
                        m_CurDir += "/"
                    End If
                    m_CurDir = m_CurDir.TrimStart("/".ToCharArray())
                End Set
            End Property

            Public Sub New()
            End Sub
            Public Sub New(ByVal sFTPSite As String, ByVal sUserName As String, ByVal sPassword As String)
                UserName = sUserName
                Password = sPassword
                FTPSite = sFTPSite
            End Sub

            Public Function GetFileList(ByVal CurDirectory As String, ByVal StartsWith As String, ByVal EndsWith As String) As List(Of String)
                CurrentDirectory = CurDirectory
                Return GetFileList(StartsWith, EndsWith)
            End Function
            Public Function GetFileList(ByVal StartsWith As String, ByVal EndsWith As String) As List(Of String)
                Dim oFTP As FtpWebRequest = DirectCast(FtpWebRequest.Create(FTPSite & CurrentDirectory), FtpWebRequest)
                'oFTP.EnableSsl = true;
                oFTP.Credentials = New NetworkCredential(UserName, Password)
                oFTP.KeepAlive = KeepAlive
                ' Validate the server certificate with
                ' ServerCertificateValidationCallBack
                If UseSSL Then
                    oFTP.EnableSsl = UseSSL
                    ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidarCertificado)
                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
                End If
                ' si usamos proxy
                If UsePxy Then
                    oFTP.Proxy = dev_proxy(ProxyHost, ProxyPort, UserNamePxy, PasswordPxy)
                End If
                'System.Security.Cryptography.X509Certificates.
                'X509Certificate oCert = new System.Security.Cryptography.
                'X509Certificates.X509Certificate();
                'oFTP.ClientCertificates.Add(oCert);

                oFTP.Method = WebRequestMethods.Ftp.ListDirectory
                Dim response As FtpWebResponse = DirectCast(oFTP.GetResponse(), FtpWebResponse)
                Dim sr As New StreamReader(response.GetResponseStream())
                Dim str As String = sr.ReadLine()
                Dim oList As New List(Of String)()
                While str IsNot Nothing
                    If str.StartsWith(StartsWith) AndAlso str.EndsWith(EndsWith) Then
                        oList.Add(str)
                    End If
                    str = sr.ReadLine()
                End While
                sr.Close()
                response.Close()
                oFTP = Nothing

                Return oList
            End Function
            Public Function GetFile(ByVal Name As String, ByVal DestFile As String, ByRef pgb As ProgressBar, ByRef lbl As Label) As Boolean
                Try
                    If FTPFileexists(Name) = True Then
                        Dim totsize As Long = FTPtamaño(Name)
                        '1. Create a request: must be in ftp://hostname format,
                        '   not just ftp.myhost.com
                        Dim oFTP As FtpWebRequest = DirectCast(FtpWebRequest.Create(FTPSite & CurrentDirectory & Name), FtpWebRequest)
                        'oFTP.EnableSsl = true;
                        '2. Set credentials
                        oFTP.Credentials = New NetworkCredential(UserName, Password)
                        'Define the action required (in this case, download
                        '                            a file)
                        oFTP.Method = WebRequestMethods.Ftp.DownloadFile
                        '3. Settings
                        oFTP.KeepAlive = KeepAlive
                        ' Validate the server certificate with
                        ' ServerCertificateValidationCallBack
                        If UseSSL Then
                            oFTP.EnableSsl = UseSSL
                            ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidarCertificado)
                            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
                        End If
                        ' si usamos proxy
                        If UsePxy Then
                            oFTP.Proxy = dev_proxy(ProxyHost, ProxyPort, UserNamePxy, PasswordPxy)
                        End If

                        'we want a binary transfer, not textual data
                        'oFTP.UseBinary = True

                        '4. If we were using a method that uploads data;
                        '   for example, UploadFile, we would open the
                        '   ftp.GetRequestStream here an send the data

                        '5. Get the response to the Ftp request and the
                        '   associated stream
                        'Debug.Print(Uri.UriSchemeFtp.ToString())


                        Dim response As FtpWebResponse = DirectCast(oFTP.GetResponse(), FtpWebResponse)
                        Dim responseStream As Stream = response.GetResponseStream()
                        'loop to read & write to file
                        Dim fs As New FileStream(DestFile, FileMode.Create)
                        Dim buffer As [Byte]() = New [Byte](2046) {}
                        Dim read As Integer = 1
                        pgb.Maximum = totsize
                        pgb.Value = 0
                        While read <> 0
                            read = responseStream.Read(buffer, 0, buffer.Length)
                            fs.Write(buffer, 0, read)
                            pgb.Value = pgb.Value + read
                            lbl.Text = String.Format("Descargado archivo :" & Name & "    [{0:#.##}%]", ((pgb.Value / pgb.Maximum) * 100))
                            lbl.Refresh()
                        End While
                        'see Note(1)
                        responseStream.Close()
                        fs.Flush()
                        fs.Close()
                        responseStream.Close()
                        response.Close()
                        oFTP = Nothing
                        Return True
                    Else
                        Return False
                    End If
                Catch ex As System.Security.SecurityException
                    Return False
                    MsgBox(ex.Message)
                Catch ex As System.Security.HostProtectionException
                    MsgBox(ex.Message)
                    Return False
                Catch ex As System.Net.Sockets.SocketException
                    MsgBox(ex.Message)
                    Return False
                Catch ex As System.Net.WebException
                    MsgBox(ex.Message)
                    Return False
                Catch ex As Exception
                    MsgBox(ex.Message)
                    Return False
                End Try

            End Function
            Public Function UploadFile(ByVal oFile1 As String, ByRef pgb As ProgressBar, ByRef lbl As Label) As Boolean
                Dim oFTP As FtpWebRequest
                Dim ftpResponse As FtpWebResponse
                Dim ofile As New System.IO.FileInfo(oFile1)

                Try
                    'Settings required to establish a connection with
                    'the server
                    oFTP = DirectCast(FtpWebRequest.Create(FTPSite & CurrentDirectory & oFile.Name), FtpWebRequest)
                    oFTP.Method = WebRequestMethods.Ftp.UploadFile
                    oFTP.Proxy = Nothing
                    oFTP.UseBinary = True
                    oFTP.Credentials = New NetworkCredential(UserName, Password)
                    oFTP.KeepAlive = KeepAlive
                    If UseSSL Then
                        oFTP.EnableSsl = UseSSL
                        ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidarCertificado)
                        ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
                    End If
                    ' si usamos proxy
                    If UsePxy Then
                        oFTP.Proxy = dev_proxy(ProxyHost, ProxyPort, UserNamePxy, PasswordPxy)
                    End If
                    'Selection of file to be uploaded
                    Dim fileContents As Byte() = New Byte(oFile.Length - 1) {}
                    pgb.Maximum = 4
                    pgb.Value = 0
                    lbl.Text = String.Format("Subiendo archivo :" & oFile.Name & "    [{0:#.##}%]", ((pgb.Value / pgb.Maximum) * 100))
                    lbl.Refresh()
                    'will destroy the object immediately after being used
                    Using fr As FileStream = oFile.OpenRead()
                        fr.Read(fileContents, 0, Convert.ToInt32(oFile.Length))
                    End Using
                    pgb.Value = 1
                    lbl.Text = String.Format("Subiendo archivo :" & oFile.Name & "    [{0:#.##}%]", ((pgb.Value / pgb.Maximum) * 100))
                    lbl.Refresh()
                    Using writer As Stream = oFTP.GetRequestStream()
                        writer.Write(fileContents, 0, fileContents.Length)
                    End Using
                    'Gets the FtpWebResponse of the uploading operation
                    ftpResponse = DirectCast(oFTP.GetResponse(), FtpWebResponse)
                    'Display response
                    'Response.Write(ftpResponse.StatusDescription);
                    pgb.Value = 2
                    lbl.Text = String.Format("Subiendo archivo :" & oFile.Name & "    [{0:#.##}%]", ((pgb.Value / pgb.Maximum) * 100))
                    lbl.Refresh()

                    ftpResponse.Close()
                    oFTP = Nothing
                    'comprobar si se subio completo
                    pgb.Value = 3
                    lbl.Text = String.Format("Subiendo archivo :" & oFile.Name & "    [{0:#.##}%]", ((pgb.Value / pgb.Maximum) * 100))
                    lbl.Refresh()
                    If FTPtamaño(oFile.Name) = oFile.Length Then
                        pgb.Value = 4
                        lbl.Text = String.Format("Subiendo archivo :" & oFile.Name & "    [{0:#.##}%]", ((pgb.Value / pgb.Maximum) * 100))
                        lbl.Refresh()
                        Return True
                    Else
                        pgb.Value = 4
                        lbl.Text = String.Format("Subiendo archivo :" & oFile.Name & "    [{0:#.##}%]", ((pgb.Value / pgb.Maximum) * 100))
                        lbl.Refresh()
                        Return False
                    End If

                Catch ex As WebException
                    MessageBox.Show(ex.Message)
                    Return False
                End Try
            End Function
            Public Function DeleteFile(ByVal Name As String) As Boolean
                Try


                    '1. Create a request: must be in ftp://hostname format,
                    '   not just ftp.myhost.com
                    Dim oFTP As FtpWebRequest = DirectCast(FtpWebRequest.Create(FTPSite & CurrentDirectory & Name), FtpWebRequest)
                    'oFTP.EnableSsl = true;
                    '2. Set credentials
                    oFTP.Credentials = New NetworkCredential(UserName, Password)
                    'Define the action required (in this case, download a file)
                    oFTP.Method = WebRequestMethods.Ftp.DeleteFile

                    '3. Settings
                    oFTP.KeepAlive = KeepAlive
                    oFTP.EnableSsl = UseSSL
                    ' Validate the server certificate with
                    ' ServerCertificateValidationCallBack
                    If UseSSL Then
                        oFTP.EnableSsl = UseSSL
                        ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidarCertificado)
                        ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
                    End If
                    ' si usamos proxy
                    If UsePxy Then
                        oFTP.Proxy = dev_proxy(ProxyHost, ProxyPort, UserNamePxy, PasswordPxy)
                    End If
                    'we want a binary transfer, not textual data
                    oFTP.UseBinary = True
                    '4. If we were using a method that uploads data;
                    '   for example, UploadFile, we would open the
                    ' ftp.GetRequestStream here an send the data

                    '5. Get the response to the Ftp request and the associated
                    '   stream
                    Dim response As FtpWebResponse = DirectCast(oFTP.GetResponse(), FtpWebResponse)
                    Dim oStat As FtpStatusCode = response.StatusCode
                    response.Close()
                    oFTP = Nothing

                    Return True
                Catch ex As Exception
                    Return False
                End Try
            End Function
            ' DeleteFile()
            Public Function FTPFileexists(ByVal Name As String) As Boolean
                FTPFileexists = False
                Try
                    Dim oFTP As FtpWebRequest = DirectCast(FtpWebRequest.Create(FTPSite & CurrentDirectory & Name), FtpWebRequest)
                    oFTP.Credentials = New NetworkCredential(UserName, Password)
                    'solo si tenemos proxy
                    oFTP.Method = WebRequestMethods.Ftp.GetFileSize
                    If UseSSL Then
                        oFTP.EnableSsl = UseSSL
                        ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidarCertificado)
                        ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
                    End If
                    ' si usamos proxy
                    If UsePxy Then
                        oFTP.Proxy = dev_proxy(ProxyHost, ProxyPort, UserNamePxy, PasswordPxy)
                    End If

                    Dim response As FtpWebResponse = DirectCast(oFTP.GetResponse(), FtpWebResponse)
                    FTPFileexists = True
                Catch ex As System.Net.WebException
                    FTPFileexists = False
                Catch ex As Exception
                    FTPFileexists = False
                End Try

            End Function
            Public Function FTPtamaño(ByVal Name As String) As Long
                FTPtamaño = 0
                Dim oFTP As FtpWebRequest = DirectCast(FtpWebRequest.Create(FTPSite & CurrentDirectory & Name), FtpWebRequest)
                oFTP.Credentials = New NetworkCredential(UserName, Password)
                'solo si tenemos proxy
                Try
                    If UseSSL Then
                        oFTP.EnableSsl = UseSSL
                        ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidarCertificado)
                        ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
                    End If
                    ' si usamos proxy
                    If UsePxy Then
                        oFTP.Proxy = dev_proxy(ProxyHost, ProxyPort, UserNamePxy, PasswordPxy)
                    End If
                    oFTP.Method = WebRequestMethods.Ftp.GetFileSize

                    Dim resp As FtpWebResponse = DirectCast(oFTP.GetResponse(), FtpWebResponse)
                    FTPtamaño = resp.ContentLength
                Catch ex As System.Net.WebException
                    FTPtamaño = 0
                Catch ex As Exception
                    FTPtamaño = 0
                End Try

            End Function
            Private Shared Function ValidarCertificado(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As System.Net.Security.SslPolicyErrors) As Boolean
                'bypass de la validación del certificado (aplicar aquí validación personalizada si fuera el caso)
                Debug.Print(certificate.Subject)
                chain.ChainPolicy.VerificationFlags = X509VerificationFlags.IgnoreCtlSignerRevocationUnknown
                chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck
                chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EndCertificateOnly
    '            Return (certificate.Subject = "E=xxxxxxxxx, OU=xxxxxx, O=xxxxxxxxx, L=xxxxx, S=xxxxxx, C=CL, CN=xxxxxxxxx")
    return true

            End Function
            Public Function dev_proxy(ByVal host As String, ByVal puerto As Integer, ByVal usuario As String, ByVal contraseNa As String) As System.Net.WebProxy
                Dim prxy As New System.Net.WebProxy
                '/proxy
                prxy = New System.Net.WebProxy(host, CType(puerto, Integer))
                prxy.Credentials = New NetworkCredential(usuario, contraseNa)
                prxy.BypassProxyOnLocal = True
                dev_proxy = prxy
            End Function
        End Class
    End Namespace

    A.E.M.C. ____________________________________________________________ Todos somos muy ignorantes. Lo que ocurre es que no todos ignoramos las mismas cosas.
    • Proposed as answer by Alex Mora Thursday, January 19, 2012 2:14 PM
    Tuesday, November 2, 2010 3:51 PM