public async Task UnboundCertificateCommitAndRefreshWorks() { using (BatchClient batchClient = ClientUnitTestCommon.CreateDummyClient()) { string pfxFilePath = TestCommon.GetTemporaryCertificateFilePath("unboundcertificateunittest.pfx"); try { CertificateBuilder.CreateSelfSignedInFile("test", pfxFilePath, CommonResources.CertificatePassword); const string expectedThumbprint = "ABC"; var protoCertificate = new Protocol.Models.Certificate(thumbprint: expectedThumbprint); Certificate certificate = batchClient.CertificateOperations.CreateCertificate( pfxFilePath, CommonResources.CertificatePassword); Assert.NotNull(certificate.ThumbprintAlgorithm); await certificate.CommitAsync(additionalBehaviors : InterceptorFactory.CreateAddCertificateRequestInterceptor()); await certificate.RefreshAsync(additionalBehaviors : InterceptorFactory.CreateGetCertificateRequestInterceptor(protoCertificate)); Assert.Equal(expectedThumbprint, certificate.Thumbprint); Assert.Null(certificate.ThumbprintAlgorithm); } finally { File.Delete(pfxFilePath); } } }
public void TestCreateSha256Pfx() { string filePath = IntegrationTestCommon.GetTemporaryCertificateFilePath(string.Format("{0}.pfx", CertificateFilePrefix)); CertificateBuilder.CreateSelfSignedInFile("Foo", filePath, CertificateBuilder.Sha256Algorithm, password: CommonResources.CertificatePassword); TestCertificateFromRawData(filePath, CertificateBuilder.Sha256Algorithm, CommonResources.CertificatePassword); }
public void TestCreateCerFileFromRawData() { string filePath = IntegrationTestCommon.GetTemporaryCertificateFilePath(string.Format("{0}.cer", CertificateFilePrefix)); CertificateBuilder.CreateSelfSignedInFile("Foo", filePath, CertificateBuilder.Sha1Algorithm); TestCertificateFromRawData(filePath, CertificateBuilder.Sha1Algorithm); }
public void TestCreatePfxFileFromRawData() { string filePath = TestCommon.GetTemporaryCertificateFilePath(string.Format("{0}.pfx", CertificateFilePrefix)); CertificateBuilder.CreateSelfSignedInFile("Foo", filePath, CommonResources.CertificatePassword); TestCertificateFromRawData(filePath, CommonResources.CertificatePassword); }
private static List <Certificate> GenerateCertificates(BatchClient batchClient, string cerFilePath, string pfxFilePath) { CertificateBuilder.CreateSelfSignedInFile("Foo", cerFilePath, CertificateBuilder.Sha1Algorithm); CertificateBuilder.CreateSelfSignedInFile("Foo", pfxFilePath, CertificateBuilder.Sha1Algorithm, password: CommonResources.CertificatePassword); Certificate cerCertificate = batchClient.CertificateOperations.CreateCertificate(cerFilePath); Certificate pfxCertificate = batchClient.CertificateOperations.CreateCertificate(pfxFilePath, CommonResources.CertificatePassword); return(new List <Certificate> { cerCertificate, pfxCertificate }); }