Secure in SessionOptions is set to "False" for S3 connections in WinSCP 6.1.1

Advertisement

Ali23
Joined:
Posts:
1

Secure in SessionOptions is set to "False" for S3 connections in WinSCP 6.1.1

In the documentation (https://winscp.net/eng/docs/library_sessionoptions) it says that the Secure option in SessionOptions is by default True for S3, however when I try to transfer a file to a S3 server its actually False by default and has to be set to True.

The script is made in PowerShell and run on PowerShell 7.3.3 on a Windows Server 2016. It was working fine (default=True) until WinSCP 5.21.3 (Build 12800 2022-09-06). When updated to WinSCP 6.1.1 it was changed to False.

Here is the script:
# Path to WinSCP DLL
$global:winscpPath = "C:\MFT\WinSCPnet.dll"
 
# Load WinSCP .NET assembly
Add-Type -Path "C:\MFT\WinSCPnet.dll"
 
# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::S3
    HostName = "s3.eu-west-1.amazonaws.com"
    UserName = "*************"
    Password = "*************"
}
 
$session = New-Object WinSCP.Session
$session.SessionLogPath = "C:\MFT\Integrations\MFT000\aws_test_log.log"
 
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
 
# As some servers does not support updating timestamps of remote files.
$transferOptions.PreserveTimestamp = $False
 
$sessionOptions.AddRawSettings("S3DefaultRegion", "eu-west-1")
 
try
{
    # Connect
    $session.Open($sessionOptions)
 
    # Your code
    $session.PutFiles("C:\Files\*", "/datalakeraw/", $False, $transferOptions)
}
finally
{
    $session.Dispose()
}

A session log is attached (log is for WinSCP 6.1.2).
  • aws_test_log.log (16.08 KB, Private file)

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,837
Location:
Prague, Czechia

To be exact, there was no Secure in 5.21.3.
But indeed in 5.21.3, the encryption was always enabled for S3.
The latest version supports even non-encrypted S3.
Setting Protocol to ''S3'' still enables encryption by default, but only when the HostName is not set (and it then defaults to s3.amazonaws.com).
What breaks it is you setting HostName to s3.eu-west-1.amazonaws.com. First of all, you should not include the region to hostname. WinSCP does that for you. So removing your HostName assignment should fix it.

Reply with quote

Advertisement

You can post new topics in this forum