Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,12 @@ public bool IgnoreEncryptedAuthSafes
/// <see langword="false" /> to fail loading when duplicate attributes are found.
/// The default is <see langword="false" />.
/// </value>
internal bool AllowDuplicateAttributes
#if NET10_0_OR_GREATER
public
#else
internal
#endif
bool AllowDuplicateAttributes
{
get => _allowDuplicateAttributes;
set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public abstract partial class X509CertificateLoaderPkcs12CollectionTests
#if NETFRAMEWORK
X509KeyStorageFlags.DefaultKeySet;
#else
PlatformDetection.UsesAppleCrypto ?
PlatformDetection.UsesAppleCrypto ?
X509KeyStorageFlags.DefaultKeySet :
X509KeyStorageFlags.EphemeralKeySet;
#endif
Expand Down Expand Up @@ -301,7 +301,7 @@ private void LoadKnownFormat_Fails(byte[] data, string path, X509ContentType con
Assert.Equal(contentType, actualType);
}
}

if (path is null)
{
Assert.ThrowsAny<CryptographicException>(() => LoadPfxNoFile(data));
Expand Down Expand Up @@ -749,14 +749,19 @@ public void LoadWithDuplicateAttributes(bool allowDuplicates)
{
Pkcs12LoaderLimits limits = Pkcs12LoaderLimits.Defaults;

#if !NET10_0_OR_GREATER
if (allowDuplicates)
{
limits = Pkcs12LoaderLimits.DangerousNoLimits;
}
#endif

// remove the edit lock
limits = new Pkcs12LoaderLimits(limits)
{
#if NET10_0_OR_GREATER
AllowDuplicateAttributes = allowDuplicates,
#endif
PreserveCertificateAlias = false,
PreserveKeyName = false,
PreserveStorageProvider = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public abstract partial class X509CertificateLoaderPkcs12Tests
#if NETFRAMEWORK
X509KeyStorageFlags.DefaultKeySet;
#else
PlatformDetection.UsesAppleCrypto ?
PlatformDetection.UsesAppleCrypto ?
X509KeyStorageFlags.DefaultKeySet :
X509KeyStorageFlags.EphemeralKeySet;
#endif
Expand Down Expand Up @@ -302,7 +302,7 @@ private void LoadKnownFormat_Fails(byte[] data, string path, X509ContentType con
Assert.Equal(contentType, actualType);
}
}

if (path is null)
{
Assert.ThrowsAny<CryptographicException>(() => LoadPfxNoFile(data));
Expand Down Expand Up @@ -744,14 +744,19 @@ public void LoadWithDuplicateAttributes(bool allowDuplicates)
{
Pkcs12LoaderLimits limits = Pkcs12LoaderLimits.Defaults;

#if !NET10_0_OR_GREATER
if (allowDuplicates)
{
limits = Pkcs12LoaderLimits.DangerousNoLimits;
}
#endif

// remove the edit lock
limits = new Pkcs12LoaderLimits(limits)
{
#if NET10_0_OR_GREATER
AllowDuplicateAttributes = allowDuplicates,
#endif
PreserveCertificateAlias = false,
PreserveKeyName = false,
PreserveStorageProvider = false,
Expand Down Expand Up @@ -788,7 +793,7 @@ public void LoadWithLegacyProvider(bool preserveStorageProvider, bool ephemeralI

// EphemeralKeySet is not available by name in the netfx build.
const X509KeyStorageFlags EphemeralKeySet = (X509KeyStorageFlags)0x20;
bool expectLegacy = (flags & EphemeralKeySet) == 0 && preserveStorageProvider;
bool expectLegacy = (flags & EphemeralKeySet) == 0 && preserveStorageProvider;

using (X509Certificate2 cert = LoadPfxNoFile(TestData.SChannelPfx, TestData.PlaceholderPw, flags, limits))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3386,6 +3386,7 @@ public sealed partial class Pkcs12LoaderLimits
{
public Pkcs12LoaderLimits() { }
public Pkcs12LoaderLimits(System.Security.Cryptography.X509Certificates.Pkcs12LoaderLimits copyFrom) { }
public bool AllowDuplicateAttributes { get { throw null; } set { } }
public static System.Security.Cryptography.X509Certificates.Pkcs12LoaderLimits DangerousNoLimits { get { throw null; } }
public static System.Security.Cryptography.X509Certificates.Pkcs12LoaderLimits Defaults { get { throw null; } }
public bool IgnoreEncryptedAuthSafes { get { throw null; } set { } }
Expand Down
Loading