-
Notifications
You must be signed in to change notification settings - Fork 34
Add configuration overrides for BaseEncoding, ForceFileSystem, and ServerCertificateValidationCallback (#46, #41, #33) #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| namespace CoreFtp.Enum | ||
| { | ||
| public enum FtpFileSystemType | ||
| { | ||
| Windows, | ||
| Unix | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,7 @@ | ||||||||||
| namespace CoreFtp | ||||||||||
| { | ||||||||||
| using System; | ||||||||||
| using System.Net.Security; | ||||||||||
| using System.Security.Authentication; | ||||||||||
| using System.Security.Cryptography.X509Certificates; | ||||||||||
| using Enum; | ||||||||||
|
|
@@ -26,5 +28,24 @@ public class FtpClientConfiguration | |||||||||
|
|
||||||||||
| public X509CertificateCollection ClientCertificates { get; set; } = new X509CertificateCollection(); | ||||||||||
| public SslProtocols SslProtocols { get; set; } = SslProtocols.None; | ||||||||||
|
|
||||||||||
| /// <summary> | ||||||||||
| /// Base encoding to use for the control stream. Useful for legacy servers that use Shift_JIS, GBK, etc. | ||||||||||
| /// </summary> | ||||||||||
| public System.Text.Encoding BaseEncoding { get; set; } = System.Text.Encoding.ASCII; | ||||||||||
|
|
||||||||||
| /// <summary> | ||||||||||
| /// Allows overriding the server certificate validation logic (e.g., verifying a specific self-signed certificate thumbprint). | ||||||||||
|
||||||||||
| /// Allows overriding the server certificate validation logic (e.g., verifying a specific self-signed certificate thumbprint). | |
| /// Allows overriding the server certificate validation logic (e.g., verifying a specific self-signed certificate thumbprint). | |
| /// Note: This callback is only invoked when <see cref="IgnoreCertificateErrors"/> is set to <c>false</c>. | |
| /// When <see cref="IgnoreCertificateErrors"/> is <c>true</c> (the default), certificate errors are ignored and this callback is not used. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -469,6 +469,9 @@ private bool OnValidateCertificate(X509Certificate certificate, X509Chain chain, | |
| if (Configuration.IgnoreCertificateErrors) | ||
| return true; | ||
|
|
||
| if (Configuration.ServerCertificateValidationCallback != null) | ||
| return Configuration.ServerCertificateValidationCallback(certificate, chain, errors); | ||
|
Comment on lines
+472
to
+473
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
|
|
||
| return errors == SslPolicyErrors.None; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
ForceFileSystemis set and the server also supportsMLSD, the code bypassesMlsdDirectoryProviderentirely and falls back toListDirectoryProvider. SinceForceFileSystemis checked first (before theUsesMlsd()check), setting it on a server that does advertiseMLSDcauses a regression: the client uses the less-capableLIST-based provider instead of the more reliableMLSD-based one.The intent from issue #41 is to handle the case where MLSD is not available and auto-detection of the
LISTformat fails. The fix should only applyForceFileSystemwhen MLSD is not available — either by changing the condition to!this.UsesMlsd() && Configuration.ForceFileSystem.HasValue, or by restructuring the check soForceFileSystemonly influences the parser selection within theLIST-based path, not the MLSD selection.