Skip to content

Commit 74ac225

Browse files
authored
Drop support for OpenSSL primitives on macOS
1 parent e0eea1f commit 74ac225

File tree

6 files changed

+20
-140
lines changed

6 files changed

+20
-140
lines changed

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static bool OpenSslPresentOnSystem
109109
{
110110
get
111111
{
112-
if (IsWindows || IsAndroid || UsesMobileAppleCrypto || IsBrowser)
112+
if (IsWindows || IsAndroid || IsApplePlatform || IsBrowser)
113113
{
114114
return false;
115115
}
@@ -250,7 +250,7 @@ private static DistroInfo GetDistroInfo()
250250
else if (line.StartsWith("VERSION_ID=", StringComparison.Ordinal))
251251
{
252252
string versionId = line.Substring(11).Trim('"', '\'');
253-
int dashIndex = versionId.IndexOf('_'); // Strip prerelease info if any (needed for Alpine Edge)
253+
int dashIndex = versionId.IndexOf('_'); // Strip prerelease info if any (needed for Alpine Edge)
254254
if (dashIndex != -1)
255255
{
256256
versionId = versionId.Substring(0, dashIndex);

src/libraries/System.Security.Cryptography.OpenSsl/tests/System.Security.Cryptography.OpenSsl.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
4-
<!-- The library is not supported on mobile platforms (PNSE) -->
5-
<IgnoreForCI Condition="'$(TargetOS)' == 'android' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos'">true</IgnoreForCI>
4+
<!-- The library is not supported on Android / Apple (PNSE) -->
5+
<IgnoreForCI Condition="'$(TargetOS)' == 'android' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'osx'">true</IgnoreForCI>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
</PropertyGroup>
88
<ItemGroup>

src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj

Lines changed: 15 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
<UseAndroidCrypto Condition="'$(TargetPlatformIdentifier)' == 'android'">true</UseAndroidCrypto>
1919
<UseAppleCrypto Condition="'$(TargetPlatformIdentifier)' == 'osx' or '$(TargetPlatformIdentifier)' == 'ios' or '$(TargetPlatformIdentifier)' == 'tvos'">true</UseAppleCrypto>
2020
<UseOpenSsl Condition="'$(TargetPlatformIdentifier)' == 'unix'">true</UseOpenSsl>
21-
<UseOpenSslAead Condition="'$(UseOpenSsl)' == 'true' or '$(TargetPlatformIdentifier)' == 'osx'">true</UseOpenSslAead>
22-
<NeedOpenSslInitializer Condition="'$(UseOpenSslAead)' == 'true'">true</NeedOpenSslInitializer>
2321
<DefineConstants Condition="'$(Configuration)' == 'Debug'">$(DefineConstants);DESIGNTIMEINTERFACES</DefineConstants>
2422
</PropertyGroup>
2523

@@ -870,18 +868,11 @@
870868
<Compile Include="System\Security\Cryptography\X509Certificates\X509Pal.NotSupported.cs" />
871869
</ItemGroup>
872870

873-
<ItemGroup Condition="'$(NeedOpenSslInitializer)' == 'true'">
874-
<Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs"
875-
Link="Common\Interop\Unix\Interop.Libraries.cs" />
876-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.ERR.cs"
877-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.ERR.cs" />
878-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.Initialization.cs"
879-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.Initialization.cs" />
880-
</ItemGroup>
881-
882871
<ItemGroup Condition="'$(UseOpenSsl)' == 'true'">
883872
<Compile Include="$(CommonPath)Interop\Unix\Interop.Errors.cs"
884873
Link="Common\Interop\Unix\Interop.Errors.cs" />
874+
<Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs"
875+
Link="Common\Interop\Unix\Interop.Libraries.cs" />
885876
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetEUid.cs"
886877
Link="Common\Interop\Unix\System.Native\Interop.GetEUid.cs" />
887878
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetPwUid.cs"
@@ -910,8 +901,12 @@
910901
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EcKey.cs" />
911902
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.Encode.cs"
912903
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.Encode.cs" />
904+
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.ERR.cs"
905+
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.ERR.cs" />
913906
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.cs"
914907
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.cs" />
908+
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.Cipher.cs"
909+
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.Cipher.cs" />
915910
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.DigestAlgs.cs"
916911
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.DigestAlgs.cs" />
917912
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.Kdf.cs"
@@ -954,6 +949,8 @@
954949
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.Rsa.cs" />
955950
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.Hmac.cs"
956951
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.Hmac.cs" />
952+
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.Initialization.cs"
953+
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.Initialization.cs" />
957954
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.LegacyAlgorithms.cs"
958955
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.LegacyAlgorithms.cs" />
959956
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.LookupFriendlyNameByOid.cs"
@@ -962,6 +959,8 @@
962959
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.OCSP.cs" />
963960
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.OCSP.Chain.cs"
964961
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.OCSP.Chain.cs" />
962+
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSslAvailable.cs"
963+
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSslAvailable.cs" />
965964
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSslVersion.cs"
966965
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSslVersion.cs" />
967966
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.Pkcs7.cs"
@@ -988,6 +987,8 @@
988987
Link="Common\Microsoft\Win32\SafeHandles\SafeDsaHandle.Unix.cs" />
989988
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\SafeEcKeyHandle.Unix.cs"
990989
Link="Common\Microsoft\Win32\SafeHandles\SafeEcKeyHandle.Unix.cs" />
990+
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\SafeEvpCipherCtxHandle.Unix.cs"
991+
Link="Common\Microsoft\Win32\SafeHandles\SafeEvpCipherCtxHandle.Unix.cs" />
991992
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\SafeEvpKdfHandle.Unix.cs"
992993
Link="Common\Microsoft\Win32\SafeHandles\SafeEvpKdfHandle.Unix.cs" />
993994
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\SafeEvpMdCtxHandle.Unix.cs"
@@ -1036,6 +1037,7 @@
10361037
Link="Common\System\Text\UrlBase64Encoding.cs" />
10371038
<Compile Include="$(CommonPath)System\Text\ValueUtf8Converter.cs"
10381039
Link="Common\System\Text\ValueUtf8Converter.cs" />
1040+
<Compile Include="System\Security\Cryptography\AesCcm.OpenSsl.cs" />
10391041
<Compile Include="System\Security\Cryptography\AesGcm.OpenSsl.cs" />
10401042
<Compile Include="System\Security\Cryptography\AesImplementation.OpenSsl.cs" />
10411043
<Compile Include="System\Security\Cryptography\AsnFormatter.OpenSsl.cs" />
@@ -1131,15 +1133,6 @@
11311133
<Compile Include="System\Security\Cryptography\X509Certificates\X509Pal.OpenSsl.cs" />
11321134
<Compile Include="System\Security\Cryptography\X509Certificates\X509Persistence.cs" />
11331135
</ItemGroup>
1134-
<ItemGroup Condition="'$(UseOpenSslAead)' == 'true'">
1135-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSslAvailable.cs"
1136-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSslAvailable.cs" />
1137-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.Cipher.cs"
1138-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.Cipher.cs" />
1139-
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\SafeEvpCipherCtxHandle.Unix.cs"
1140-
Link="Common\Microsoft\Win32\SafeHandles\SafeEvpCipherCtxHandle.Unix.cs" />
1141-
<Compile Include="System\Security\Cryptography\AesCcm.OpenSsl.cs" />
1142-
</ItemGroup>
11431136

11441137
<ItemGroup Condition="'$(UseAndroidCrypto)' == 'true'">
11451138
<Compile Include="$(CommonPath)Interop\Android\Interop.JObjectLifetime.cs"
@@ -1416,82 +1409,24 @@
14161409
</ItemGroup>
14171410

14181411
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'osx'">
1419-
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\Asn1SafeHandles.Unix.cs"
1420-
Link="Common\Microsoft\Win32\SafeHandles\Asn1SafeHandles.Unix.cs" />
1421-
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\SafeBignumHandle.Unix.cs"
1422-
Link="Common\Microsoft\Win32\SafeHandles\SafeBignumHandle.Unix.cs" />
1423-
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\SafeDsaHandle.Unix.cs"
1424-
Link="Common\Microsoft\Win32\SafeHandles\SafeDsaHandle.Unix.cs" />
1425-
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\SafeEcKeyHandle.Unix.cs"
1426-
Link="Common\Microsoft\Win32\SafeHandles\SafeEcKeyHandle.Unix.cs" />
1427-
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\SafeInteriorHandle.cs"
1428-
Link="Common\Microsoft\Win32\SafeHandles\SafeInteriorHandle.cs" />
1429-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.ASN1.cs"
1430-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.ASN1.cs" />
1431-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.ASN1.Nid.cs"
1432-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.ASN1.Nid.cs" />
1433-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.Bignum.cs"
1434-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.Bignum.cs" />
1435-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.Dsa.cs"
1436-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.Dsa.cs" />
1437-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EcKey.cs"
1438-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EcKey.cs" />
1439-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EcDsa.ImportExport.cs"
1440-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EcDsa.ImportExport.cs" />
1441-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.DigestAlgs.cs"
1442-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.DigestAlgs.cs" />
1443-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.cs"
1444-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.cs" />
1445-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.Dsa.cs"
1446-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.Dsa.cs" />
1447-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.Ecdh.cs"
1448-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.Ecdh.cs" />
1449-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.EcDsa.cs"
1450-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.EcDsa.cs" />
1451-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.EcKey.cs"
1452-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.EcKey.cs" />
1453-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.Rsa.cs"
1454-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.Rsa.cs" />
1455-
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSslVersion.cs"
1456-
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSslVersion.cs" />
14571412
<Compile Include="$(CommonPath)Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.Keychain.macOS.cs"
14581413
Link="Common\Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.Keychain.macOS.cs" />
14591414
<Compile Include="$(CommonPath)Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.SecKeyRef.macOS.cs"
14601415
Link="Common\Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.SecKeyRef.macOS.cs" />
14611416
<Compile Include="$(CommonPath)Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.X509.macOS.cs"
14621417
Link="Common\Interop\OSX\System.Security.Cryptography.Native.Apple\Interop.X509.macOS.cs" />
1463-
<Compile Include="$(CommonPath)System\Security\Cryptography\DSAOpenSsl.cs"
1464-
Link="Common\System\Security\Cryptography\DSAOpenSsl.cs" />
14651418
<Compile Include="$(CommonPath)System\Security\Cryptography\DSASecurityTransforms.cs"
14661419
Link="Common\System\Security\Cryptography\DSASecurityTransforms.cs" />
14671420
<Compile Include="$(CommonPath)System\Security\Cryptography\DSASecurityTransforms.macOS.cs"
14681421
Link="Common\System\Security\Cryptography\DSASecurityTransforms.macOS.cs" />
14691422
<Compile Include="$(CommonPath)System\Security\Cryptography\EccSecurityTransforms.macOS.cs"
14701423
Link="Common\System\Security\Cryptography\EccSecurityTransforms.macOS.cs" />
1471-
<Compile Include="$(CommonPath)System\Security\Cryptography\ECDiffieHellmanOpenSsl.cs"
1472-
Link="Common\System\Security\Cryptography\ECDiffieHellmanOpenSsl.cs" />
1473-
<Compile Include="$(CommonPath)System\Security\Cryptography\ECDiffieHellmanOpenSsl.Derive.cs"
1474-
Link="Common\System\Security\Cryptography\ECDiffieHellmanOpenSsl.Derive.cs" />
1475-
<Compile Include="$(CommonPath)System\Security\Cryptography\ECDiffieHellmanOpenSslPublicKey.cs"
1476-
Link="Common\System\Security\Cryptography\ECDiffieHellmanOpenSslPublicKey.cs" />
1477-
<Compile Include="$(CommonPath)System\Security\Cryptography\ECDsaOpenSsl.cs"
1478-
Link="Common\System\Security\Cryptography\ECDsaOpenSsl.cs" />
1479-
<Compile Include="$(CommonPath)System\Security\Cryptography\ECOpenSsl.cs"
1480-
Link="Common\System\Security\Cryptography\ECOpenSsl.cs" />
1481-
<Compile Include="$(CommonPath)System\Security\Cryptography\ECOpenSsl.ImportExport.cs"
1482-
Link="Common\System\Security\Cryptography\ECOpenSsl.ImportExport.cs" />
14831424
<Compile Include="$(CommonPath)System\Security\Cryptography\RSASecurityTransforms.macOS.cs"
14841425
Link="Common\System\Security\Cryptography\RSASecurityTransforms.macOS.cs" />
1485-
<Compile Include="$(CommonPath)System\Security\Cryptography\RSAOpenSsl.cs"
1486-
Link="Common\System\Security\Cryptography\RSAOpenSsl.cs" />
1426+
<Compile Include="System\Security\Cryptography\AesCcm.NotSupported.cs" />
14871427
<Compile Include="System\Security\Cryptography\DSA.Create.SecurityTransforms.cs" />
14881428
<Compile Include="System\Security\Cryptography\DSACryptoServiceProvider.Unix.cs" />
1489-
<Compile Include="System\Security\Cryptography\DSAOpenSsl.cs" />
1490-
<Compile Include="System\Security\Cryptography\ECDsaOpenSsl.cs" />
1491-
<Compile Include="System\Security\Cryptography\ECDiffieHellmanOpenSsl.cs" />
1492-
<Compile Include="System\Security\Cryptography\RSAOpenSsl.cs" />
1493-
<Compile Include="System\Security\Cryptography\SafeEvpPKeyHandle.OpenSsl.cs" />
1494-
<Compile Include="System\Security\Cryptography\SafeEvpPKeyHandle.OpenSsl.macOS.cs" />
1429+
<Compile Include="System\Security\Cryptography\OpenSsl.NotSupported.cs" />
14951430
<Compile Include="System\Security\Cryptography\X509Certificates\AppleCertificatePal.ImportExport.macOS.cs" />
14961431
<Compile Include="System\Security\Cryptography\X509Certificates\AppleCertificatePal.Keys.macOS.cs" />
14971432
<Compile Include="System\Security\Cryptography\X509Certificates\AppleCertificatePal.Pkcs12.macOS.cs" />

src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/SafeEvpPKeyHandle.OpenSsl.macOS.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/libraries/System.Security.Cryptography/tests/AesCcmTests.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -708,17 +708,7 @@ public static void CtorThrowsPNSEIfNotSupported()
708708
[Fact]
709709
public static void CheckIsSupported()
710710
{
711-
bool expectedIsSupported = !PlatformDetection.IsBrowser;
712-
713-
if (PlatformDetection.IsOSX)
714-
{
715-
expectedIsSupported = PlatformDetection.OpenSslPresentOnSystem;
716-
}
717-
else if (PlatformDetection.UsesMobileAppleCrypto)
718-
{
719-
expectedIsSupported = false;
720-
}
721-
711+
bool expectedIsSupported = !PlatformDetection.IsBrowser && !PlatformDetection.IsApplePlatform;
722712
Assert.Equal(expectedIsSupported, AesCcm.IsSupported);
723713
}
724714
}

src/libraries/tests.proj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@
4040
<HighAOTResourceRequiringProject Include="$(MSBuildThisFileDirectory)System.Text.Json\tests\System.Text.Json.Tests\System.Text.Json.Tests.csproj" />
4141
</ItemGroup>
4242

43-
<ItemGroup Condition="'$(TargetOS)' == 'osx' and '$(TargetArchitecture)' == 'arm64'">
44-
<!-- https://github.com/dotnet/dnceng/issues/3008 - osx Helix queue doesn't have OpenSSL -->
45-
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Security.Cryptography.OpenSsl\tests\System.Security.Cryptography.OpenSsl.Tests.csproj" />
46-
</ItemGroup>
47-
4843
<ItemGroup Condition="'$(TargetOS)' == 'browser'">
4944
<!-- Samples which are too complex for CI -->
5045
<ProjectExclusions Include="$(MonoProjectRoot)sample\wasm\console-node-ts\Wasm.Console.Node.TS.Sample.csproj" />

0 commit comments

Comments
 (0)