-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[API Proposal]: LdapSessionOptions.CertificateDirectory Property #104260
Comments
Tagging subscribers to this area: @dotnet/area-system-directoryservices, @jay98014 |
I think this is misguided. There's an existing API for certificate validation ( (*) See #60972 for details. |
Per offline discussion with @buyaa-n, moving to future. Please close if there is a valid alternative. |
@onmp could you collaborate more on how you imagine this |
This issue has been marked |
@onmp as a work around, could you set the env variable Could try with a ldapsearch commant: Or run |
This issue has been automatically marked |
This issue will now be closed since it had been marked |
Re-opened. We have external validation that that adding namespace System.DirectoryServices.Protocols;
public class LdapSessionOptions
{
+ public string CertificateDirectory { get; set; }
+ public void StartNewTlsSessionContext();
} addresses this. Internally the LdapPal.SetStringOption(_connection._ldapHandle, LdapOption.LDAPTLS_CACERTDIR \ 0x6003, value); This will throw Usage along the lines of: Environment.SetEnvironmentVariable("LDAPTLS_CACERTDIR", Path.Combine(AppContext.BaseDirectory, "certs"));
LdapDirectoryIdentifier directoryIdentifier = new LdapDirectoryIdentifier("ldap.local", 1636, fullyQualifiedDnsHostName: true, connectionless: false);
NetworkCredential credential = new NetworkCredential("cn=admin,dc=example,dc=org", "password");
using LdapConnection connection = new LdapConnection(directoryIdentifier, credential)
{
AuthType = AuthType.Basic
};
connection.SessionOptions.ProtocolVersion = 3;
connection.SessionOptions.SecureSocketLayer = true;
Debug.Assert(OperatingSystem.IsLinux());
connection.SessionOptions.CertificateDirectory = "~/console/mycerts";
connection.SessionOptions.StartNewTLSSessionContext();
connection.Bind();
var searchRequest = new SearchRequest("DC=example,DC=org", "(objectClass=*)", SearchScope.Subtree);
_ = (SearchResponse)connection.SendRequest(searchRequest);
Console.WriteLine("Success!"); |
I will update the original API suggestion and mark it ready for reviewing pending internal discussion. |
namespace System.DirectoryServices.Protocols;
public partial class LdapSessionOptions
{
[UnsupportedOS("windows")]
[UnsupportedOS("android")]
[UnsupportedOS("browser")]
[UnsupportedOS("ios")]
public string? TrustedCertificatesDirectory { get; set; }
[UnsupportedOS("windows")]
[UnsupportedOS("android")]
[UnsupportedOS("browser")]
[UnsupportedOS("ios")]
public void StartNewTlsSessionContext();
} |
Background and motivation
This is to provide a way for those who may not have the privilege to administer the system CA certificates store or those who do not want to add entries to the system CA stores permanently but still want to verify the server certificate.
The new APIs are only for Linux and MacOS since the
LdapSessionOptions.VerifyServerCertificates
property is not supported there.API Proposal
Adds to https://learn.microsoft.com/en-us/dotnet/api/system.directoryservices.protocols.ldapsessionoptions
Assembly:
System.DirectoryServices.Protocols.dll
Internally the
CertificateDirectory
setter callsand simililarily
StartNewTLSSessionContext
setsAPI Usage
Longer example:
Backup of original proposal
API Proposal
Namespace:
System.DirectoryServices.Protocols
Assembly:
System.DirectoryServices.Protocols.dll
The property CaCertificate contains a X509CertificateCollection object with one or more CA certificates to use to verify server certificates when an SSL connection is established.
Property value
CaCertficates
CA certificates to verify server certificate.
API Usage
Alternative Designs
Have LdapSessionOptions.VerifyServerCertificates be functional.
Risks
The risk is minimal because no current application is using this property.
The text was updated successfully, but these errors were encountered: