0 votes
by (130 points)
edited

Can you please provide some assistance using this product via PowerShell. I have a script that is running using the sFTP libraries, but now have a need to use FTP/SSL.

The main issue I am having is storing and accessing the .pfx keys provided by the company we are connecting to. Has anyone done this?

Any and all help would be great.

Applies to: Rebex FTP/SSL

1 Answer

+1 vote
by (148k points)
edited

We have a blogpost describing the basics: Using FTP or SFTP in PowerShell

Getting the .pfx keys to work requires few additional lines of code. If these are client certificates that are intended for client authentication, the following code should do the trick:

[Reflection.Assembly]::LoadFrom("C:\Program Files\Rebex\FTP for .NET 2.0\bin\release\Rebex.Net.Ftp.dll")
[Reflection.Assembly]::LoadFrom("C:\Program Files\Rebex\FTP for .NET 2.0\bin\release\Rebex.Net.SecureSocket.dll")

$certificate = [Rebex.Security.Certificates.CertificateChain]::LoadPfx("c:\...\ClientCerts.pfx", "password")

$params = New-Object Rebex.Net.TlsParameters
$params.CertificateRequestHandler = [Rebex.Net.CertificateRequestHandler]::CreateRequestHandler($certificate)

$ftp = New-Object Rebex.Net.Ftp
$ftp.Connect("ftp.example.com", 21, $params, [Rebex.Net.FtpSecurity]::Explicit)

Please refer to our FTP/SSL tutorial for more information about these classes and methods.

...