/// <summary> /// Trust the PublicCert cert as leaf or self-issued. /// </summary> /// <remarks>Dispose of the object returned!</remarks> /// On MacOs, if we add the leaf or self-issued certificate into LocalMachine\Root, the private key will not be accessed. So the dotnet signing command tests will fail for: /// "Object contains only the public half of a key pair. A private key must also be provided." internal TrustedTestCert <TestCertificate> WithPrivateKeyAndTrustForLeafOrSelfIssued() { StoreName storeName = CertificateStoreUtilities.GetTrustedCertificateStoreNameForLeafOrSelfIssuedCertificate(); StoreLocation storeLocation = CertificateStoreUtilities.GetTrustedCertificateStoreLocationForLeafOrSelfIssuedCertificate(); return(new TrustedTestCert <TestCertificate>(this, e => PublicCertWithPrivateKey, storeName, storeLocation)); }
/// <summary> /// Trust the PublicCert cert as intermediate CA certificate. /// </summary> /// <remarks>Dispose of the object returned!</remarks> /// On MacOs, there is no StoreName.CertificateAuthority, so add to LocalMachine\My instead. internal TrustedTestCert <TestCertificate> WithPrivateKeyAndTrustForIntermediateCertificateAuthority() { StoreName storeName = CertificateStoreUtilities.GetCertificateAuthorityStoreName(); StoreLocation storeLocation = CertificateStoreUtilities.GetTrustedCertificateStoreLocation(); return(new TrustedTestCert <TestCertificate>(this, e => PublicCertWithPrivateKey, storeName, storeLocation)); }
/// <summary> /// Trust the PublicCert cert for the life of the object. /// </summary> /// <remarks>Dispose of the object returned!</remarks> public TrustedTestCert <TestCertificate> WithPrivateKeyAndTrust(StoreName storeName = StoreName.TrustedPeople) { StoreLocation storeLocation = CertificateStoreUtilities.GetTrustedCertificateStoreLocation(); return(new TrustedTestCert <TestCertificate>(this, e => PublicCertWithPrivateKey, storeName, storeLocation)); }
/// <summary> /// Trust the PublicCert cert for the life of the object. /// </summary> /// <remarks>Dispose of the object returned!</remarks> /// According to https://github.com/dotnet/corefx/blob/master/Documentation/architecture/cross-platform-cryptography.md#x509store /// Linux could not read/write LocalMachine\Root , but could only read/write CurrentUser\Root public TrustedTestCert <TestCertificate> WithTrust() { StoreLocation storeLocation = CertificateStoreUtilities.GetTrustedCertificateStoreLocation(); return(new TrustedTestCert <TestCertificate>(this, e => PublicCert, StoreName.Root, storeLocation)); }