-
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
[release/9.0-staging] Add support for LDAPTLS_CACERTDIR \ TrustedCertificateDirectory #112531
Open
steveharter
wants to merge
2
commits into
dotnet:release/9.0-staging
Choose a base branch
from
steveharter:backport-pr-1118770-to-release-9.0-staging
base: release/9.0-staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/libraries/System.DirectoryServices.Protocols/src/CompatibilitySuppressions.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids --> | ||
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<Suppression> | ||
<DiagnosticId>CP0002</DiagnosticId> | ||
<Target>M:System.DirectoryServices.Protocols.LdapSessionOptions.get_TrustedCertificatesDirectory</Target> | ||
<Left>lib/net8.0/System.DirectoryServices.Protocols.dll</Left> | ||
<Right>lib/net8.0/System.DirectoryServices.Protocols.dll</Right> | ||
<IsBaselineSuppression>true</IsBaselineSuppression> | ||
</Suppression> | ||
<Suppression> | ||
<DiagnosticId>CP0002</DiagnosticId> | ||
<Target>M:System.DirectoryServices.Protocols.LdapSessionOptions.set_TrustedCertificatesDirectory(System.String)</Target> | ||
<Left>lib/net8.0/System.DirectoryServices.Protocols.dll</Left> | ||
<Right>lib/net8.0/System.DirectoryServices.Protocols.dll</Right> | ||
<IsBaselineSuppression>true</IsBaselineSuppression> | ||
</Suppression> | ||
<Suppression> | ||
<DiagnosticId>CP0002</DiagnosticId> | ||
<Target>M:System.DirectoryServices.Protocols.LdapSessionOptions.StartNewTlsSessionContext</Target> | ||
<Left>lib/net8.0/System.DirectoryServices.Protocols.dll</Left> | ||
<Right>lib/net8.0/System.DirectoryServices.Protocols.dll</Right> | ||
<IsBaselineSuppression>true</IsBaselineSuppression> | ||
</Suppression> | ||
<Suppression> | ||
<DiagnosticId>CP0002</DiagnosticId> | ||
<Target>M:System.DirectoryServices.Protocols.LdapSessionOptions.get_TrustedCertificatesDirectory</Target> | ||
<Left>lib/net9.0/System.DirectoryServices.Protocols.dll</Left> | ||
<Right>lib/net9.0/System.DirectoryServices.Protocols.dll</Right> | ||
<IsBaselineSuppression>true</IsBaselineSuppression> | ||
</Suppression> | ||
<Suppression> | ||
<DiagnosticId>CP0002</DiagnosticId> | ||
<Target>M:System.DirectoryServices.Protocols.LdapSessionOptions.set_TrustedCertificatesDirectory(System.String)</Target> | ||
<Left>lib/net9.0/System.DirectoryServices.Protocols.dll</Left> | ||
<Right>lib/net9.0/System.DirectoryServices.Protocols.dll</Right> | ||
<IsBaselineSuppression>true</IsBaselineSuppression> | ||
</Suppression> | ||
<Suppression> | ||
<DiagnosticId>CP0002</DiagnosticId> | ||
<Target>M:System.DirectoryServices.Protocols.LdapSessionOptions.StartNewTlsSessionContext</Target> | ||
<Left>lib/net9.0/System.DirectoryServices.Protocols.dll</Left> | ||
<Right>lib/net9.0/System.DirectoryServices.Protocols.dll</Right> | ||
<IsBaselineSuppression>true</IsBaselineSuppression> | ||
</Suppression> | ||
<Suppression> | ||
<DiagnosticId>CP0002</DiagnosticId> | ||
<Target>M:System.DirectoryServices.Protocols.LdapSessionOptions.get_TrustedCertificatesDirectory</Target> | ||
<Left>lib/netstandard2.0/System.DirectoryServices.Protocols.dll</Left> | ||
<Right>lib/netstandard2.0/System.DirectoryServices.Protocols.dll</Right> | ||
<IsBaselineSuppression>true</IsBaselineSuppression> | ||
</Suppression> | ||
<Suppression> | ||
<DiagnosticId>CP0002</DiagnosticId> | ||
<Target>M:System.DirectoryServices.Protocols.LdapSessionOptions.set_TrustedCertificatesDirectory(System.String)</Target> | ||
<Left>lib/netstandard2.0/System.DirectoryServices.Protocols.dll</Left> | ||
<Right>lib/netstandard2.0/System.DirectoryServices.Protocols.dll</Right> | ||
<IsBaselineSuppression>true</IsBaselineSuppression> | ||
</Suppression> | ||
<Suppression> | ||
<DiagnosticId>CP0002</DiagnosticId> | ||
<Target>M:System.DirectoryServices.Protocols.LdapSessionOptions.StartNewTlsSessionContext</Target> | ||
<Left>lib/netstandard2.0/System.DirectoryServices.Protocols.dll</Left> | ||
<Right>lib/netstandard2.0/System.DirectoryServices.Protocols.dll</Right> | ||
<IsBaselineSuppression>true</IsBaselineSuppression> | ||
</Suppression> | ||
</Suppressions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,6 +2,8 @@ | |||||
// The .NET Foundation licenses this file to you under the MIT license. | ||||||
|
||||||
using System.ComponentModel; | ||||||
using System.IO; | ||||||
using System.Runtime.Versioning; | ||||||
|
||||||
namespace System.DirectoryServices.Protocols | ||||||
{ | ||||||
|
@@ -11,6 +13,34 @@ public partial class LdapSessionOptions | |||||
|
||||||
private bool _secureSocketLayer; | ||||||
|
||||||
/// <summary> | ||||||
/// Specifies the path of the directory containing CA certificates in the PEM format. | ||||||
/// Multiple directories may be specified by separating with a semi-colon. | ||||||
/// </summary> | ||||||
/// <remarks> | ||||||
/// The certificate files are looked up by the CA subject name hash value where that hash can be | ||||||
/// obtained by using, for example, <code>openssl x509 -hash -noout -in CA.crt</code>. | ||||||
/// It is a common practice to have the certificate file be a symbolic link to the actual certificate file | ||||||
/// which can be done by using <code>openssl rehash .</code> or <code>c_rehash .</code> in the directory | ||||||
/// containing the certificate files. | ||||||
/// </remarks> | ||||||
/// <exception cref="DirectoryNotFoundException">The directory not exist.</exception> | ||||||
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. Minor grammar issue: 'The directory not exist.' should be 'The directory does not exist.'
Suggested change
Copilot is powered by AI, so mistakes are possible. Review output carefully before use. |
||||||
[UnsupportedOSPlatform("windows")] | ||||||
public string TrustedCertificatesDirectory | ||||||
{ | ||||||
get => GetStringValueHelper(LdapOption.LDAP_OPT_X_TLS_CACERTDIR, releasePtr: true); | ||||||
|
||||||
set | ||||||
{ | ||||||
if (!Directory.Exists(value)) | ||||||
{ | ||||||
throw new DirectoryNotFoundException(SR.Format(SR.DirectoryNotFound, value)); | ||||||
} | ||||||
|
||||||
SetStringOptionHelper(LdapOption.LDAP_OPT_X_TLS_CACERTDIR, value); | ||||||
} | ||||||
} | ||||||
|
||||||
public bool SecureSocketLayer | ||||||
{ | ||||||
get | ||||||
|
@@ -52,6 +82,16 @@ public ReferralChasingOptions ReferralChasing | |||||
} | ||||||
} | ||||||
|
||||||
/// <summary> | ||||||
/// Create a new TLS library context. | ||||||
/// Calling this is necessary after setting TLS-based options, such as <c>TrustedCertificatesDirectory</c>. | ||||||
/// </summary> | ||||||
[UnsupportedOSPlatform("windows")] | ||||||
public void StartNewTlsSessionContext() | ||||||
{ | ||||||
SetIntValueHelper(LdapOption.LDAP_OPT_X_TLS_NEWCTX, 0); | ||||||
} | ||||||
|
||||||
private bool GetBoolValueHelper(LdapOption option) | ||||||
{ | ||||||
if (_connection._disposed) throw new ObjectDisposedException(GetType().Name); | ||||||
|
@@ -71,5 +111,14 @@ private void SetBoolValueHelper(LdapOption option, bool value) | |||||
|
||||||
ErrorChecking.CheckAndSetLdapError(error); | ||||||
} | ||||||
|
||||||
private void SetStringOptionHelper(LdapOption option, string value) | ||||||
{ | ||||||
if (_connection._disposed) throw new ObjectDisposedException(GetType().Name); | ||||||
|
||||||
int error = LdapPal.SetStringOption(_connection._ldapHandle, option, value); | ||||||
|
||||||
ErrorChecking.CheckAndSetLdapError(error); | ||||||
} | ||||||
} | ||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is OK for now - but if we wanted to make this more common we could let projects opt out of this setting -
runtime/eng/packaging.targets
Line 41 in b61c07c