TLS/SSL Implicit error running from .Net Code, but can manually copy via GUI.

Advertisement

htony
Joined:
Posts:
2

TLS/SSL Implicit error running from .Net Code, but can manually copy via GUI.

Hello,
I am having issues copying to TLS/SSL Implicit Server setup from .NET code. On the same machine I am able to copy via the GUI with no issues. Via Code a "425 Can't open data connection" error is being thrown.

This is on a Windows Server 2012 R2 box and I am using version 5.17.1 (build 11087) of WinSCP. I have the WinSCPnet.dll installed in the GAC. Below is the VB.NET code and I have attached two log files, one created via code and one created via the GUI.
Try
    Dim sessionOptions As New SessionOptions
    With sessionOptions
        .Protocol = Protocol.Ftp
        .HostName = "hostName"
        .UserName = "UserName"
        .Password = "Password"
        .FtpSecure = FtpSecure.Implicit
        .TlsHostCertificateFingerprint = "FP"
    End With
 
    Using session As New Session
        session.SessionLogPath = "log.txt"
        session.DebugLogLevel = 2
        session.ExecutablePath = "C:\Program Files (x86)\WinSCP\WinSCP.exe"
        ' Connect
        session.Open(sessionOptions)
        ' Download files
        Dim transferOptions As New TransferOptions
        transferOptions.TransferMode = TransferMode.Binary
        transferOptions.ResumeSupport.State = TransferResumeSupportState.On
        Dim transferResult As TransferOperationResult = Nothing
        transferResult = session.PutFiles()
        ' Throw on any error
        If transferResult IsNot Nothing Then transferResult.Check()
    End Using
Catch ex As Exception
   MsgBox(ex.ToString)
End Try
  • LogViaGui.txt (19.77 KB, Private file)
  • logViaCode.txt (12.28 KB, Private file)

Reply with quote E-mail

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,517
Location:
Prague, Czechia

Re: TLS/SSL Implicit error running from .Net Code, but can manually copy via GUI.

Can you try doing Session.ListDirectory before the Session.PutFiles? It seems there's some problem with the first data connection, possibly due to TLS session reuse.
session.ListDirectory("/some/path")
You can also try setting raw session settings SslSessionReuse to "0":
sessionOptions.AddRawSettings("SslSessionReuse", "0")

Reply with quote

Advertisement

You can post new topics in this forum