Quantcast
Channel: Alex FTPS Client
Viewing all 114 articles
Browse latest View live

New Post: How can I upload a file using TLS 1.0 Protocol?

$
0
0
Hi All,

I found the solution.

There is a third party open source you can download from the url https://ftps.codeplex.com/

you need to open this source and you will see a file FTPSClient.cs. Find the below line of code.

//sslStream.AuthenticateAsClient(hostname);
sslStream.AuthenticateAsClient(hostname, clientCertColl, SslProtocols.Default, sslCheckCertRevocation);

You will see SslProtocols.Default (by default it uses SSL3) you need to change this to SslProtocols.Tls

Now you are ready to upload a file with TLS protocol.

Now you can use the AlexPilotti.FTPS.Client.dll in your VB.NET by adding it to reference.

Using client As New FTPSClient()
client.Connect("ftp.XXXXX.com", New NetworkCredential("XXXXX", "XXXXX"), ESSLSupportMode.CredentialsRequired Or ESSLSupportMode.DataChannelRequested)
client.PutFile("E:\test.txt","Test" + DateTime.Now.ToString("yyyyMMddHH") + DateTime.Now.Ticks.ToString() + "." + "txt")
End Using

Uploading via Ftp over TLS Protocol is done.

New Post: Connection terminated without SSL shutdown

$
0
0
Hi,

I use this ftps library in my software. Everything works fine, except one thing. On ftps server side I get message in log: "Connection terminated without SSL shutdown - buggy client?". Is something wrong on my code or library does not implement something?
Except this message in server side log. everything works good (establishing connection, sending files, etc.).

regards,
Mike

Reviewed: AlexFTPS Client 1.1.0 (Jan 14, 2015)

$
0
0
Rated 5 Stars (out of 5) - This is a time saving (LOCs) library! Excellent work, Alex!

Created Unassigned: Downloading and registering a CA Certificate [9498]

$
0
0
Hello!

I am having an issue when trying to FTPS into a server using the FTPSClient. The error is as follows.

> The remote certificate is invalid according to the validation procedure.

What I need to do is download the CA certificate from the server I'm trying to FTPS into and then add that to the trusted list of certificates and I was wondering if anyone could help me with instructions on how I might be able to do that?

The operating system I am attempting to do this on is Windows 7 Professional.

Thank you for any assistance you can provide!

New Post: Multi upload or FTP command

$
0
0
Dear users,

I create a small script to upload files, here the code:
 ftps -h username.bplaced.net -U username_ftp -P password -ssl CredentialsRequired  -noCopyrightInfo -sslInvalidServerCertHandling Accept -p /xampp/htdocs/infofiles/*.php /infofiles
My problem is, I would like to change the directory, but I use -cust cd .. and nothing work. My folder structure is:
-htdocs
    |_img
    |_infofiles
    |_infofiles_text
Thx, for help
[FPS]

New Post: FTP SSL Implicit failed with error "AuthenticationException: A call to SSPI failed"

$
0
0
Hi everyone,

I am having the same problem, and after a lot of investigation, I found out that the problem occurs only from windows server 2012
It is not happening in windows server 2008 or in Windows 7.

The error messages receiving are:

A call to SSPI failed, see inner exception.

with inner exception:
The message received was unexpected or badly formatted

And this error is occurring during the call of .GetListing() method. (connection succeeds)

Can anyone help please?
Thanks in advance

Created Unassigned: Feature list not trimmed (many symptoms possible) [9526]

$
0
0
My symptom:
__ERROR: The handshake failed due to an unexpected packet format.__

Using an Implicit FTP connection. It worked with Filezilla client.
By comparing the filezilla client output and my code, I fixed my problem by issuing 2 further commands:
FTPReply reply1 = client.SendCustomCommand("PBSZ 0");
FTPReply reply2 = client.SendCustomCommand("PROT P");

But then found on this forum that this has already been addressed in this patch:
https://ftps.codeplex.com/SourceControl/changeset/74297
from a discussion here:
https://ftps.codeplex.com/discussions/349204

Turns out my problem lies with feature listing.

FTPSClient.cs:

```
private IList<string> FeatCmd()
{
FTPReply reply = HandleCmd("FEAT");
IList<string> features = new List<string>(reply.Message.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries));
features.RemoveAt(0);
features.RemoveAt(features.Count - 1);

return features;
}
```

The customer ftp server is now returning this to me:

```
Extensions supported:
EPSV
MDTM
PASV
REST STREAM
SIZE
UTF8
PBSZ
PROT
X-NOVELLABS
X-CITRIX
End.
```

Note the leading space!

In my case, this means FeatCmd() ends up returning features like " PBSZ" (with leading space) and " PROT" (with leading space). And the code in SslDataChannelImplicitEncryptionRequest which call:
```
CheckFeature("PBSZ") && CheckFeature("PROT")
```
doesn't get run!

I imagine many symptoms are possible, anything that calls CheckFeature and if the server returns a list of features with trailing spaces.

My fix is to add this line:
```
for (int i = 0; i < features.Count; i++) features[i] = features[i].Trim();
```
in method FeatCmd() in FTPSClient.cs, full method becomes:
```
private IList<string> FeatCmd()
{
FTPReply reply = HandleCmd("FEAT");
IList<string> features = new List<string>(reply.Message.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries));
features.RemoveAt(0);
features.RemoveAt(features.Count - 1);
for (int i = 0; i < features.Count; i++) features[i] = features[i].Trim();
return features;
}
```

Although I'm a bit confused why this has suddenly appeared on my customer's ftp server. Searching the web, I found that the FEAT command must include the leading space:
https://tools.ietf.org/html/rfc3659#section-3.3

New Post: PROT P required

$
0
0
Had "ERROR: The handshake failed due to an unexpected packet format." it worked in Filezilla which seems to issue PBSZ 0 and PROT P commands, but it failed in AlexFtps, even with the patch mentioned! In my case, the problem came from server returning features with a leading space, therefore the call to PROT P was never done. See my post+fix here:
https://ftps.codeplex.com/workitem/9526

New Post: Error while Trasferring file to FTPS

$
0
0
Hi ,
We are using this for FTPS transfer,
It was working fine before, but now it is giving us this error while putting file to FTPS,

It is able to connect to FTPS server,
FTPSClient outClient = new FTPSClient()

outClient.Connect(ServerName,
                            nPort,
                            new NetworkCredential(UserId, UserPassword),
                            ESSLSupportMode.Implicit,
                            new RemoteCertificateValidationCallback(ValidateServerCertificate),
                            new X509Certificate(KeyLocation),
                            0, 0, 0, int.Parse(WaitingMin) * 60, false, eConnectionMode);

outClient.SetTransferMode(eTransferMode);

outClient.PutFile(@sFilePath, FileMask);
The following is the error which started appearing,
It is able to connect to the FTPS server, but unable to put the file there.

:::Error Message: Data connections must be encrypted.

:::Stack Trace: at AlexPilotti.FTPS.Client.FTPSClient.GetReply()
at AlexPilotti.FTPS.Client.FTPSClient.HandleCmd(String command, Boolean waitForAnswer)
at AlexPilotti.FTPS.Client.FTPSClient.StorCmd(String fileName)
at AlexPilotti.FTPS.Client.FTPSClient.PutFile(String remoteFileName)
at AlexPilotti.FTPS.Client.FTPSClient.PutFile(String localFileName, String remoteFileName, FileTransferCallback transferCallback)

New Post: Help with Powershell Connect()

$
0
0
String Connect(
     String hostname,
     Int32 port,
     NetworkCredential credential,
     ESSLSupportMode sslSupportMode,
     RemoteCertificateValidationCallback userValidateServerCertificate,
     X509Certificate x509ClientCert,
     Int32 sslMinKeyExchangeAlgStrength,
     Int32 sslMinCipherAlgStrength,
     Int sslMinHashAlgStrength,
     Nullable `1 timeout,
     Boolean useCtrlEndPointAddressForData,
     EDataConnectionMode dataConnectionMode
)
After falling fowl of FTPWebRequest too many times I want to replace it with something else in my automation scripts so I fancy giving a different approach a try. I'm stumbling on the first hurdle though which is establishing a connection - I need to do so via port 2121, which means using at least 6 of the above parameters.

I'm not all that familiar with RemoteCertificateValidationCallback and X509Certificate - can anyone help me out? The servers I'm connecting to do not support SSL, so I imagine mostly dummy data is required?

Commented Issue: Error: The Handle is Invalid [1598]

$
0
0
I am running the following ftps command in a bat file (leaving out pwd):
 
ftps -h web1 -U ciserver -P ***** -ssl All -sslInvalidServerCertHandling Accept -p g:/cis/StagingCIS_vss_metrosearchonline/working/src/Web/* /web/ -r
 
 
 
The bat file is executed from my continuous integration server. The bat file has been tested to run directly from the "run" command as well as directly from a cmd window. All files are copied successfully. When the continuous build server attempts to run the bat file, however, it only copies the first file in the web folder and then closes the connection with the following error:
 
"Error: The Handle is Invalid"
 
My continuous integration server is CruiseControl.net. The following task is part of cruise control's process to run the bat file (it runs after the build task):
<exec>
<executable>G:\CIS\StagingCIS_vss_metrosearchonline\taskscripts\vss_metrosearchonline_FTPS.bat</executable>
<baseDirectory>G:\CIS\tools\</baseDirectory>
<buildTimeoutSeconds>300</buildTimeoutSeconds>
<successExitCodes>0</successExitCodes>
<description>ftps - File Deployment</description>
</exec>
Comments: ** Comment from web user: cdonner **

I can confirm that this issue still exists - in my case when run in an SSIS script task. It would return -1 and the task failed but did not leave any trace of the reason otherwise.
I can also confirm what jonhawkins said - that rebuilding the client after commenting out all references to the screen width (_ConsoleFormatWidth_) - fixes it.
_ConsoleFormatWidth_ is obviously not a method as suggested, but it is used by a method and in a few other places to determine the formatting of the output. I didn't refactor this code, just commented it out to get it working. Some things are no longer printed to the console now, but because it runs headless anyway, that's just fine.

New Post: OPTS UTF8 ON: command not understood

$
0
0
Receiving the same error but through the .NET class library.

The server I am connecting to does not support OPTS, I do not have control of this server so need to be able to turn off OPTS in my request from the class library. Please could you explain how to do this?

The .NET code I am using:
using (FTPSClient client = new FTPSClient())
{
    client.Connect(host, credentials, ESSLSupportMode.ClearText);

    client.SetTextEncoding(ETextEncoding.ASCII);
    client.SetTransferMode(ETransferMode.ASCII);

    client.PutFile(@"c:\data\test.png");
}
In addition, the custom build you have provided has a broken link.

New Post: Recurse in Powershell

$
0
0
I am impressed with your work, but would like to see a "Recurse" functionality within the DLL Methods for use within Powershell

New Post: OPTS UTF8 ON: command not understood

$
0
0
I'm also hitting this problem against a Secure Transport 5.2.1 FTP server over which I have no control.

Would it be possible to check that the OPTS command is supported before calling SetTextEncoding(ETextEncoding.UTF8) in FTPSClient.cs?

New Post: This library is very well built

$
0
0
I did every thing i wanted , and is very easy to use .
Thanks to the author :)

Reviewed: AlexFTPS Client 1.1.0 (Nov 11, 2015)

$
0
0
Rated 5 Stars (out of 5) - Excellent Excellent Excellent Has the features to connect to FTP and FTPs . I never regretted that i invested time using it . Big thanks to the author .

New Post: Help with connecting with Certificate

$
0
0
Can someone provide me with a sample of how to connect with an X509Certificate?

Here is what I am currently doing but getting errors when I try to connect:
System.Net.Sockets.SocketException was caught
  Message=An attempt was made to access a socket in a way forbidden by its access permissions 151.151.65.207:21
  Source=System
  ErrorCode=10013
  NativeErrorCode=10013
                X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);

                store.Open(OpenFlags.ReadOnly);
                X509Certificate x509Cert = null;
                foreach (X509Certificate2 mCert in store.Certificates)
                {
                    if(mCert.FriendlyName.Contains("WF CA P12 Individual Certificate"))
                    {
                        x509Cert = mCert;
                        break;
                    }
                    
                }



                using (FTPSClient client = new FTPSClient())
                {
                   
                    string message = client.Connect(strServerAddress, 
                                    intPortNumber,
                                   new NetworkCredential(strUserName,
                                                         strPassword),
                                    ESSLSupportMode.Implicit,
                                    null,
                                    x509Cert, 0, 0, 0, null); 

                    // upload a file
                    client.PutFile(@pathFileNameWithExtension, @FTPFileNameWithExtension);

                    client.Close();

                    if (message == "")
                    {
                        errMessage = String.Format("Upload of {0} to {1} failed with the message {2}.", pathFileNameWithExtension, strServerAddress, message);
                        haveError = false;
                    }

                }

New Post: Read Failure on GetReply()

$
0
0
I've an error on tablet Android when receive reply from FTP Server.
The error is read failure and I suppose that the problem is in line
string replyLine = ctrlSr.ReadLine();

The command send RETR and after error read failure all command (SIZE...) receive error read failure

New Post: FTPS Resume Download

$
0
0
Thanks for this fantastic library. It's very useful. I have added a functionality to resume downloading.
public ulong GetFile(string remoteFileName, string localFileName, FileTransferCallback transferCallback)
{
    ...

    var localFile = new FileInfo(localFileName);
    if(localFile.Exists)
    {
        using (Stream s = GetPartOfRemoteFile(remoteFileName, localFile.Length))
        {
            // file exist append, otherwise create which is the else block
            using (var fs = new FileStream(localFileName, FileMode.Append, FileAccess.Write, FileShare.None))
            {
                ...
    }
    else
    {
        ...
    }
    ....
}
plus you will need this function
private FTPStream GetPartOfRemoteFile(string remoteFileName, long offset)
{
    SetupDataConnection();
    RestCmd(offset);
    RetrCmd(remoteFileName);
    return EndStreamCommand(FTPStream.EAllowedOperation.Read);
}
as well as a Resume command
private void RestCmd(long offset)
{
    HandleCmd($"REST {offset}");
}

New Post: FTPS Resume Download

$
0
0
Hi,

I am new to this dll. I want to pause and resume files on ftp server using this dll.
I have a requirement that, once download has started and lets say it is 20% completed, then the power failure occurs or internet got down. Then, when he starts downloading the same file, then it should resume from 20% instead of 0%.
All this i need to show in a progress bar in one of my project.
Can you tell me how to use this dll to accomplish this ?


Thanks
Amit Agrawal
Viewing all 114 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>