|
|
ed07d0 |
From bc80566e3b85f0cf00127babb3942c08fccaa013 Mon Sep 17 00:00:00 2001
|
|
|
ed07d0 |
From: Tom Deseyn <tom.deseyn@gmail.com>
|
|
|
ed07d0 |
Date: Wed, 30 May 2018 08:59:28 +0200
|
|
|
ed07d0 |
Subject: [PATCH 1/5] Skip certificates we can't read when populating machine
|
|
|
ed07d0 |
store.
|
|
|
ed07d0 |
|
|
|
ed07d0 |
This is a regression in 2.1.0 (https://github.com/dotnet/corefx/pull/29351).
|
|
|
ed07d0 |
|
|
|
ed07d0 |
Fixes https://github.com/dotnet/corefx/issues/29942.
|
|
|
ed07d0 |
---
|
|
|
ed07d0 |
.../src/Internal/Cryptography/Pal.Unix/StorePal.cs | 7 ++++++-
|
|
|
ed07d0 |
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
ed07d0 |
|
|
|
ed07d0 |
diff --git a/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/StorePal.cs b/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/StorePal.cs
|
|
|
ed07d0 |
index 3c3cdb20c59e..57b8f025b88b 100644
|
|
|
ed07d0 |
--- a/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/StorePal.cs
|
|
|
ed07d0 |
+++ b/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/StorePal.cs
|
|
|
ed07d0 |
@@ -254,7 +254,12 @@ private static void LoadMachineStores()
|
|
|
ed07d0 |
{
|
|
|
ed07d0 |
using (SafeBioHandle fileBio = Interop.Crypto.BioNewFile(file.FullName, "rb"))
|
|
|
ed07d0 |
{
|
|
|
ed07d0 |
- Interop.Crypto.CheckValidOpenSslHandle(fileBio);
|
|
|
ed07d0 |
+ // The handle may be invalid, for example when we don't have read permission for the file.
|
|
|
ed07d0 |
+ if (fileBio.IsInvalid)
|
|
|
ed07d0 |
+ {
|
|
|
ed07d0 |
+ Interop.Crypto.ErrClearError();
|
|
|
ed07d0 |
+ continue;
|
|
|
ed07d0 |
+ }
|
|
|
ed07d0 |
|
|
|
ed07d0 |
ICertificatePal pal;
|
|
|
ed07d0 |
|
|
|
ed07d0 |
|
|
|
ed07d0 |
From fd2a7c30b26825216ac35922ad51e471ffbfc123 Mon Sep 17 00:00:00 2001
|
|
|
ed07d0 |
From: Tom Deseyn <tom.deseyn@gmail.com>
|
|
|
ed07d0 |
Date: Wed, 30 May 2018 21:03:38 +0200
|
|
|
ed07d0 |
Subject: [PATCH 2/5] Add test
|
|
|
ed07d0 |
|
|
|
ed07d0 |
---
|
|
|
ed07d0 |
...rity.Cryptography.X509Certificates.Tests.csproj | 6 +++
|
|
|
ed07d0 |
.../tests/TestData.cs | 48 ++++++++++++++++++++++
|
|
|
ed07d0 |
.../tests/X509StoreTests.cs | 48 +++++++++++++++++++++-
|
|
|
ed07d0 |
3 files changed, 101 insertions(+), 1 deletion(-)
|
|
|
ed07d0 |
|
|
|
ed07d0 |
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj b/src/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj
|
|
|
ed07d0 |
index 09f919a4f438..f1d383dff6d5 100644
|
|
|
ed07d0 |
--- a/src/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj
|
|
|
ed07d0 |
+++ b/src/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj
|
|
|
ed07d0 |
@@ -90,6 +90,12 @@
|
|
|
ed07d0 |
</Compile>
|
|
|
ed07d0 |
<Compile Include="TestEnvironmentConfiguration.Unix.cs" />
|
|
|
ed07d0 |
</ItemGroup>
|
|
|
ed07d0 |
+ <ItemGroup>
|
|
|
ed07d0 |
+ <ProjectReference Include="$(CommonTestPath)\System\Diagnostics\RemoteExecutorConsoleApp\RemoteExecutorConsoleApp.csproj">
|
|
|
ed07d0 |
+ <Project>{69e46a6f-9966-45a5-8945-2559fe337827}</Project>
|
|
|
ed07d0 |
+ <Name>RemoteExecutorConsoleApp</Name>
|
|
|
ed07d0 |
+ </ProjectReference>
|
|
|
ed07d0 |
+ </ItemGroup>
|
|
|
ed07d0 |
<ItemGroup>
|
|
|
ed07d0 |
<SupplementalTestData Include="$(PackagesDir)system.security.cryptography.x509certificates.testdata\1.0.2-prerelease\content\**\*.*" />
|
|
|
ed07d0 |
</ItemGroup>
|
|
|
ed07d0 |
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/TestData.cs b/src/System.Security.Cryptography.X509Certificates/tests/TestData.cs
|
|
|
ed07d0 |
index 25b55d437b9d..5be9fd735ae4 100644
|
|
|
ed07d0 |
--- a/src/System.Security.Cryptography.X509Certificates/tests/TestData.cs
|
|
|
ed07d0 |
+++ b/src/System.Security.Cryptography.X509Certificates/tests/TestData.cs
|
|
|
ed07d0 |
@@ -80,6 +80,54 @@ internal static class TestData
|
|
|
ed07d0 |
XgSpRm3m9Xp5QL0fzehF1a7iXT71dcfmZmNgzNWahIeNJDD37zTQYx2xQmdKDku/
|
|
|
ed07d0 |
Og7vtpU6pzjkJZIIpohmgg==
|
|
|
ed07d0 |
-----END CERTIFICATE-----
|
|
|
ed07d0 |
+");
|
|
|
ed07d0 |
+
|
|
|
ed07d0 |
+ // 'cert.pem' generated using 'openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365'
|
|
|
ed07d0 |
+ public static readonly byte[] SelfSigned1PemBytes = ByteUtils.AsciiBytes(
|
|
|
ed07d0 |
+ @"-----BEGIN CERTIFICATE-----
|
|
|
ed07d0 |
+MIIDWjCCAkKgAwIBAgIJAJpCQ7mtFWHeMA0GCSqGSIb3DQEBCwUAMEIxCzAJBgNV
|
|
|
ed07d0 |
+BAYTAlhYMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1bHQg
|
|
|
ed07d0 |
+Q29tcGFueSBMdGQwHhcNM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7XEvi0hyv8PKli+Oww2Zyt1jTTvv2RTA
|
|
|
ed07d0 |
+eJRqTUNUbWEDesXAOh5CY6Xjfg7Gt6IYQHt0JMw29pXB3TV2uyXuvFNsc725cPbW
|
|
|
ed07d0 |
+JCuC9TGQRUAUj+LZ43tTrfaZ7g5L80/eRrvlx5MIJSsX8cev8pZYx224WRtk/w==
|
|
|
ed07d0 |
+-----END CERTIFICATE-----
|
|
|
ed07d0 |
+");
|
|
|
ed07d0 |
+
|
|
|
ed07d0 |
+ // 'cert.pem' generated using 'openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365'
|
|
|
ed07d0 |
+ public static readonly byte[] SelfSigned2PemBytes = ByteUtils.AsciiBytes(
|
|
|
ed07d0 |
+ @"-----BEGIN CERTIFICATE-----
|
|
|
ed07d0 |
+MIIDWjCCAkKgAwIBAgIJAM6YQ4PrC9jaMA0GCSqGSIb3DQEBCwUAMEIxCzAJBgNV
|
|
|
ed07d0 |
+BAYTAlhYMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1bHQg
|
|
|
ed07d0 |
+Q29tcGFueSBMdGQwHhcNMTgwNTMwMTgyNjQ4WhcNMTkwNTMwMTgyNjQ4WjBCMQsw
|
|
|
ed07d0 |
+CQYDVQQGEwJYWDEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5MRwwGgYDVQQKDBNEZWZh
|
|
|
ed07d0 |
+dWx0IENvbXBhbnkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
|
|
|
ed07d0 |
+7vkM6zrhXJFtrV63lUb4fsjZG2JYvSRGYv4Y/rwe7VLVdTYvMjosyvKCHJ4Frmtb
|
|
|
ed07d0 |
+YU4jJeB+859mQAd3IOBEhgUJuJ6gC8cOJAwUFJNUabeuafXG2zw/U+396csRKr11
|
|
|
ed07d0 |
+iBUpvooFJR7KLWrqPKXhK5yESV1k7OzSSZs4owmyIvSaGQO2T63S39OYJhq8ZUlO
|
|
|
ed07d0 |
++MznaOQGp2J+JWncZo9XCpiotZwdNtw5k+F1g3NAz4/+Vkah/SfQhcNCfJyfVDCX
|
|
|
ed07d0 |
+IwBS+gz9i1BIw6s+SLYtkp167yyizmVIWoXtkgCPaeG0FzBPAhL9GDLTItJ/V/O5
|
|
|
ed07d0 |
+F9SjbvS+4rUIuPSn7NdodwIDAQABo1MwUTAdBgNVHQ4EFgQUq4v4TrvYrsbKDRGF
|
|
|
ed07d0 |
+bMnj3++P9B4wHwYDVR0jBBgwFoAUq4v4TrvYrsbKDRGFbMnj3++P9B4wDwYDVR0T
|
|
|
ed07d0 |
+AQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAS4ZKEGVfIrHMmYAZe9p3jm15
|
|
|
ed07d0 |
+85OIPLlM4q6QjRccLJ4t2+xYLRU9PNa2Qmz8l+SFOy9XN9yJp79lSi1gN4lJ8ZdI
|
|
|
ed07d0 |
+kwu+zPEzwsJnb6f3zRu2RQUeAkaShDCEdxpyKHEky1KVG2nOa3cKp+pqzN4DQ3Rp
|
|
|
ed07d0 |
+cJCjcP5ncNJ0bbCZTS7w0oVvX5JhBWIigw3CN5rL2rf83CTPPBzUype0bt97sBSs
|
|
|
ed07d0 |
+dxIPtH9l/q9OgdaCrPE8KBqcwXsfNlFwYGjkqmN/v7WaysBRdblHcoWmry3YsaK2
|
|
|
ed07d0 |
+/tZo6lmYOHpdqL0OdDwlldToY7QdL1coICfHas5Ony49OHTCUZz6G/AS+3a3gQ==
|
|
|
ed07d0 |
+-----END CERTIFICATE-----
|
|
|
ed07d0 |
");
|
|
|
ed07d0 |
|
|
|
ed07d0 |
public const string PfxDataPassword = "12345";
|
|
|
ed07d0 |
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs b/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs
|
|
|
ed07d0 |
index 2bc94e2fec55..96b63ceaaa6b 100644
|
|
|
ed07d0 |
--- a/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs
|
|
|
ed07d0 |
+++ b/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs
|
|
|
ed07d0 |
@@ -2,11 +2,14 @@
|
|
|
ed07d0 |
// The .NET Foundation licenses this file to you under the MIT license.
|
|
|
ed07d0 |
// See the LICENSE file in the project root for more information.
|
|
|
ed07d0 |
|
|
|
ed07d0 |
+using System.Diagnostics;
|
|
|
ed07d0 |
+using System.IO;
|
|
|
ed07d0 |
+using System.Runtime.InteropServices;
|
|
|
ed07d0 |
using Xunit;
|
|
|
ed07d0 |
|
|
|
ed07d0 |
namespace System.Security.Cryptography.X509Certificates.Tests
|
|
|
ed07d0 |
{
|
|
|
ed07d0 |
- public class X509StoreTests
|
|
|
ed07d0 |
+ public class X509StoreTests : RemoteExecutorTestBase
|
|
|
ed07d0 |
{
|
|
|
ed07d0 |
[Fact]
|
|
|
ed07d0 |
public static void OpenMyStore()
|
|
|
ed07d0 |
@@ -496,5 +499,48 @@ public static void UnixCannotModifyDisallowedStore(bool useEnum, OpenFlags openF
|
|
|
ed07d0 |
Assert.Equal(0, store.Certificates.Count);
|
|
|
ed07d0 |
}
|
|
|
ed07d0 |
}
|
|
|
ed07d0 |
+
|
|
|
ed07d0 |
+ [Fact]
|
|
|
ed07d0 |
+ [PlatformSpecific(TestPlatforms.AnyUnix)]
|
|
|
ed07d0 |
+ private void X509Store_MachineStoreLoadSkipsInvalidFiles()
|
|
|
ed07d0 |
+ {
|
|
|
ed07d0 |
+ // We create a folder for our machine store and use it by setting SSL_CERT_{DIR,FILE}.
|
|
|
ed07d0 |
+ // In the store we'll add some invalid files, but we start and finish with a valid file.
|
|
|
ed07d0 |
+ // This is to account for the order in which the store is populated.
|
|
|
ed07d0 |
+ string sslCertDir = GetTestFilePath();
|
|
|
ed07d0 |
+ Directory.CreateDirectory(sslCertDir);
|
|
|
ed07d0 |
+
|
|
|
ed07d0 |
+ // Valid file.
|
|
|
ed07d0 |
+ File.WriteAllBytes(Path.Combine(sslCertDir, "0.pem"), TestData.SelfSigned1PemBytes);
|
|
|
ed07d0 |
+
|
|
|
ed07d0 |
+ // File with invalid content.
|
|
|
ed07d0 |
+ File.WriteAllText(Path.Combine(sslCertDir, "1.pem"), "This is not a valid cert");
|
|
|
ed07d0 |
+
|
|
|
ed07d0 |
+ // File which is not readable by the current user.
|
|
|
ed07d0 |
+ string unreadableFileName = Path.Combine(sslCertDir, "2.pem");
|
|
|
ed07d0 |
+ File.WriteAllText(unreadableFileName, string.Empty);
|
|
|
ed07d0 |
+ chmod(unreadableFileName, 0);
|
|
|
ed07d0 |
+
|
|
|
ed07d0 |
+ // Valid file.
|
|
|
ed07d0 |
+ File.WriteAllBytes(Path.Combine(sslCertDir, "3.pem"), TestData.SelfSigned2PemBytes);
|
|
|
ed07d0 |
+
|
|
|
ed07d0 |
+ var psi = new ProcessStartInfo();
|
|
|
ed07d0 |
+ psi.Environment.Add("SSL_CERT_DIR", sslCertDir);
|
|
|
ed07d0 |
+ psi.Environment.Add("SSL_CERT_FILE", "/nonexisting");
|
|
|
ed07d0 |
+ RemoteInvoke(() =>
|
|
|
ed07d0 |
+ {
|
|
|
ed07d0 |
+ using (var store = new X509Store(StoreName.Root, StoreLocation.LocalMachine))
|
|
|
ed07d0 |
+ {
|
|
|
ed07d0 |
+ store.Open(OpenFlags.OpenExistingOnly);
|
|
|
ed07d0 |
+
|
|
|
ed07d0 |
+ // Check nr of certificates in store.
|
|
|
ed07d0 |
+ Assert.Equal(2, store.Certificates.Count);
|
|
|
ed07d0 |
+ }
|
|
|
ed07d0 |
+ return SuccessExitCode;
|
|
|
ed07d0 |
+ }, new RemoteInvokeOptions { StartInfo = psi }).Dispose();
|
|
|
ed07d0 |
+ }
|
|
|
ed07d0 |
+
|
|
|
ed07d0 |
+ [DllImport("libc")]
|
|
|
ed07d0 |
+ private static extern int chmod(string path, int mode);
|
|
|
ed07d0 |
}
|
|
|
ed07d0 |
}
|
|
|
ed07d0 |
|
|
|
ed07d0 |
From 0a4ffb5f547bc990f9bc0e849ee0e4c4f816c720 Mon Sep 17 00:00:00 2001
|
|
|
ed07d0 |
From: Tom Deseyn <tom.deseyn@gmail.com>
|
|
|
ed07d0 |
Date: Thu, 31 May 2018 08:17:34 +0200
|
|
|
ed07d0 |
Subject: [PATCH 3/5] Assert chmod returns 0
|
|
|
ed07d0 |
|
|
|
ed07d0 |
---
|
|
|
ed07d0 |
.../tests/X509StoreTests.cs | 2 +-
|
|
|
ed07d0 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
ed07d0 |
|
|
|
ed07d0 |
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs b/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs
|
|
|
ed07d0 |
index 96b63ceaaa6b..82dba736c108 100644
|
|
|
ed07d0 |
--- a/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs
|
|
|
ed07d0 |
+++ b/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs
|
|
|
ed07d0 |
@@ -519,7 +519,7 @@ private void X509Store_MachineStoreLoadSkipsInvalidFiles()
|
|
|
ed07d0 |
// File which is not readable by the current user.
|
|
|
ed07d0 |
string unreadableFileName = Path.Combine(sslCertDir, "2.pem");
|
|
|
ed07d0 |
File.WriteAllText(unreadableFileName, string.Empty);
|
|
|
ed07d0 |
- chmod(unreadableFileName, 0);
|
|
|
ed07d0 |
+ Assert.Equal(0, chmod(unreadableFileName, 0));
|
|
|
ed07d0 |
|
|
|
ed07d0 |
// Valid file.
|
|
|
ed07d0 |
File.WriteAllBytes(Path.Combine(sslCertDir, "3.pem"), TestData.SelfSigned2PemBytes);
|
|
|
ed07d0 |
|
|
|
ed07d0 |
From 2e5c99e9a6e0bc114459947a3ba3f87b145632d1 Mon Sep 17 00:00:00 2001
|
|
|
ed07d0 |
From: Tom Deseyn <tom.deseyn@gmail.com>
|
|
|
ed07d0 |
Date: Thu, 31 May 2018 09:39:43 +0200
|
|
|
ed07d0 |
Subject: [PATCH 4/5] Skip test on OSX
|
|
|
ed07d0 |
|
|
|
ed07d0 |
---
|
|
|
ed07d0 |
.../tests/X509StoreTests.cs | 2 +-
|
|
|
ed07d0 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
ed07d0 |
|
|
|
ed07d0 |
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs b/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs
|
|
|
ed07d0 |
index 82dba736c108..ba1e9142f716 100644
|
|
|
ed07d0 |
--- a/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs
|
|
|
ed07d0 |
+++ b/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs
|
|
|
ed07d0 |
@@ -501,7 +501,7 @@ public static void UnixCannotModifyDisallowedStore(bool useEnum, OpenFlags openF
|
|
|
ed07d0 |
}
|
|
|
ed07d0 |
|
|
|
ed07d0 |
[Fact]
|
|
|
ed07d0 |
- [PlatformSpecific(TestPlatforms.AnyUnix)]
|
|
|
ed07d0 |
+ [PlatformSpecific(TestPlatforms.Linux)] // Windows/OSX doesn't use SSL_CERT_{DIR,FILE}.
|
|
|
ed07d0 |
private void X509Store_MachineStoreLoadSkipsInvalidFiles()
|
|
|
ed07d0 |
{
|
|
|
ed07d0 |
// We create a folder for our machine store and use it by setting SSL_CERT_{DIR,FILE}.
|
|
|
ed07d0 |
|
|
|
ed07d0 |
From 80a678f1a5d29ec913e36afdda028d6fee5a7785 Mon Sep 17 00:00:00 2001
|
|
|
ed07d0 |
From: Tom Deseyn <tom.deseyn@gmail.com>
|
|
|
ed07d0 |
Date: Mon, 4 Jun 2018 15:59:01 +0200
|
|
|
ed07d0 |
Subject: [PATCH 5/5] Add valid content to the unreadable cert file
|
|
|
ed07d0 |
|
|
|
ed07d0 |
---
|
|
|
ed07d0 |
.../tests/TestData.cs | 24 ++++++++++++++++++++++
|
|
|
ed07d0 |
.../tests/X509StoreTests.cs | 4 ++--
|
|
|
ed07d0 |
2 files changed, 26 insertions(+), 2 deletions(-)
|
|
|
ed07d0 |
|
|
|
ed07d0 |
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/TestData.cs b/src/System.Security.Cryptography.X509Certificates/tests/TestData.cs
|
|
|
ed07d0 |
index 5be9fd735ae4..ff8c1614be5a 100644
|
|
|
ed07d0 |
--- a/src/System.Security.Cryptography.X509Certificates/tests/TestData.cs
|
|
|
ed07d0 |
+++ b/src/System.Security.Cryptography.X509Certificates/tests/TestData.cs
|
|
|
ed07d0 |
@@ -128,6 +128,30 @@ internal static class TestData
|
|
|
ed07d0 |
dxIPtH9l/q9OgdaCrPE8KBqcwXsfNlFwYGjkqmN/v7WaysBRdblHcoWmry3YsaK2
|
|
|
ed07d0 |
/tZo6lmYOHpdqL0OdDwlldToY7QdL1coICfHas5Ony49OHTCUZz6G/AS+3a3gQ==
|
|
|
ed07d0 |
-----END CERTIFICATE-----
|
|
|
ed07d0 |
+");
|
|
|
ed07d0 |
+
|
|
|
ed07d0 |
+ // 'cert.pem' generated using 'openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365'
|
|
|
ed07d0 |
+ public static readonly byte[] SelfSigned3PemBytes = ByteUtils.AsciiBytes(
|
|
|
ed07d0 |
+ @"-----BEGIN CERTIFICATE-----
|
|
|
ed07d0 |
+MIIDWjCCAkKgAwIBAgIJANzv9IQvr0bwMA0GCSqGSIb3DQEBCwUAMEIxCzAJBgNV
|
|
|
ed07d0 |
+BAYTAlhYMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1bHQg
|
|
|
ed07d0 |
+Q29tcGFueSBMdGQwHhcNMTgwNjA0MTMzMjIxWhcNMTkwNjA0MTMzMjIxWjBCMQsw
|
|
|
ed07d0 |
+CQYDVQQGEwJYWDEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5MRwwGgYDVQQKDBNEZWZh
|
|
|
ed07d0 |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qbyA0vi92YyyZViUa36hhVrNqPxtpclir+lcnNgnlqg==
|
|
|
ed07d0 |
+-----END CERTIFICATE-----
|
|
|
ed07d0 |
");
|
|
|
ed07d0 |
|
|
|
ed07d0 |
public const string PfxDataPassword = "12345";
|
|
|
ed07d0 |
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs b/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs
|
|
|
ed07d0 |
index ba1e9142f716..151067587bf6 100644
|
|
|
ed07d0 |
--- a/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs
|
|
|
ed07d0 |
+++ b/src/System.Security.Cryptography.X509Certificates/tests/X509StoreTests.cs
|
|
|
ed07d0 |
@@ -518,11 +518,11 @@ private void X509Store_MachineStoreLoadSkipsInvalidFiles()
|
|
|
ed07d0 |
|
|
|
ed07d0 |
// File which is not readable by the current user.
|
|
|
ed07d0 |
string unreadableFileName = Path.Combine(sslCertDir, "2.pem");
|
|
|
ed07d0 |
- File.WriteAllText(unreadableFileName, string.Empty);
|
|
|
ed07d0 |
+ File.WriteAllBytes(unreadableFileName, TestData.SelfSigned2PemBytes);
|
|
|
ed07d0 |
Assert.Equal(0, chmod(unreadableFileName, 0));
|
|
|
ed07d0 |
|
|
|
ed07d0 |
// Valid file.
|
|
|
ed07d0 |
- File.WriteAllBytes(Path.Combine(sslCertDir, "3.pem"), TestData.SelfSigned2PemBytes);
|
|
|
ed07d0 |
+ File.WriteAllBytes(Path.Combine(sslCertDir, "3.pem"), TestData.SelfSigned3PemBytes);
|
|
|
ed07d0 |
|
|
|
ed07d0 |
var psi = new ProcessStartInfo();
|
|
|
ed07d0 |
psi.Environment.Add("SSL_CERT_DIR", sslCertDir);
|