protected override void PreRun(TestContext ctx) { base.PreRun(ctx); store = BtlsProvider.CreateNativeStore(); if (Parameters.AddTrustedRoots) { store.AddTrustedRoots(); } AddTrustedRoots(ctx); chain = BtlsProvider.CreateNativeChain(); SetupChain(ctx); storeCtx = BtlsProvider.CreateNativeStoreCtx(); storeCtx.Initialize(store, chain); verifyParam = SetupVerifyParameters(ctx); if (Parameters.CheckTime != null) { verifyParam.SetTime(Parameters.CheckTime.Value); } if (Parameters.Host != null) { verifyParam.SetHost(Parameters.Host); } if (verifyParam != null) { storeCtx.SetVerifyParam(verifyParam); } }
public override void Run(TestContext ctx) { ctx.LogMessage("BORING VALIDATION RUNNER: {0}", store); var result = storeCtx.Verify(); var error = storeCtx.GetError(); ctx.LogMessage("BORING VALIDATION RUNNER #1: {0} {1}", result, error); if (Parameters.ExpectSuccess) { ctx.Assert(result, Is.EqualTo(1), "validation success"); ctx.Assert(error, Is.EqualTo(BtlsX509Error.OK), "success result"); } else { ctx.Assert(result, Is.EqualTo(0), "validation failed"); ctx.Assert(error, Is.EqualTo(Parameters.ExpectedResult), "validation result"); } using (var nativeChain = storeCtx.GetChain()) using (var managedChain = BtlsProvider.GetManagedChain(nativeChain)) { ExpectManagedChain(ctx, managedChain); ExpectNativeChain(ctx, nativeChain); } }
void AddCertificate(CertificateResourceType type) { var data = ResourceManager.GetCertificateData(type); using (var x509 = BtlsProvider.CreateNative(data, BtlsX509Format.PEM)) chain.Add(x509); }
public Task Initialize(TestContext ctx, CancellationToken cancellationToken) { return(Task.Run(() => { chain = BtlsProvider.CreateNativeChain(); PopulateChain(ctx); })); }
static BtlsX509 ReadFromStandardInput() { var text = Console.In.ReadToEnd(); var data = Encoding.UTF8.GetBytes(text); return(BtlsProvider.CreateNative(data, BtlsX509Format.PEM)); }
protected void SetupChain(TestContext ctx) { foreach (var type in Parameters.Types) { var data = ResourceManager.GetCertificateData(type); var x509 = BtlsProvider.CreateNative(data, BtlsX509Format.PEM); chain.Add(x509); } }
public Task Initialize(TestContext ctx, CancellationToken cancellationToken) { return(Task.Run(() => { store = BtlsProvider.CreateNativeStore(); if (loadTrustedRoots) { store.AddTrustedRoots(); } })); }
public void TestStore(TestContext ctx, BoringX509StoreHost store, BoringX509ChainHost chain) { ctx.LogMessage("TEST STORE: {0}", store); using (var storeCtx = BtlsProvider.CreateNativeStoreCtx()) { storeCtx.Initialize(store.Instance, chain.Instance); TestStore(ctx, storeCtx); } }
// [Martin] // [AsyncTest] public void Hello(TestContext ctx) { var chain = BtlsProvider.CreateNativeChain(); ctx.LogMessage("GOT CHAIN: {0}", chain); var tlsTestData = ResourceManager.GetCertificateData(CertificateResourceType.TlsTestXamDevNew); var tlsTestCaData = ResourceManager.GetCertificateData(CertificateResourceType.TlsTestXamDevCA); var tlsTest = BtlsProvider.CreateNative(tlsTestData, BtlsX509Format.PEM); var tlsTestCa = BtlsProvider.CreateNative(tlsTestCaData, BtlsX509Format.PEM); ctx.LogMessage("LET'S BUILD IT!"); chain.Add(tlsTest); chain.Add(tlsTestCa); var store = BtlsProvider.CreateNativeStore(); store.AddTrustedRoots(); var storeCtx = BtlsProvider.CreateNativeStoreCtx(); storeCtx.Initialize(store, chain); var param = BtlsProvider.GetVerifyParam_SslClient().Copy(); param.SetHost("test!"); param.AddHost("martin.xamdev.com"); var flags = param.GetFlags(); ctx.LogMessage("FLAGS: {0:x}", flags); // param.SetFlags (BoringX509VerifyFlags.CRL_CHECK); // param.SetPurpose (BoringX509Purpose.SMIME_ENCRYPT); param.SetTime(DateTime.Now.AddDays(3)); storeCtx.SetVerifyParam(param); ctx.LogMessage("CALLING VERIFY"); var ret = storeCtx.Verify(); ctx.LogMessage("VERIFY DONE: {0}", ret); var error = storeCtx.GetError(); ctx.LogMessage("VERIFY ERROR: {0}", error); ctx.LogMessage("STORE COUNT: {0}", store.GetCount()); }
public void Run(TestContext ctx, BoringX509Host x509) { var data = ResourceManager.GetCertificateData(ResourceType); var info = ResourceManager.GetCertificateInfo(ResourceType); if (!Managed) { BoringCertificateInfoTestRunner.TestNativeCertificate(ctx, x509.Instance, info); return; } using (var cert = BtlsProvider.CreateCertificate2(data, BtlsX509Format.PEM, true)) { CertificateInfoTestRunner.TestManagedCertificate(ctx, cert, info); } }
protected BtlsX509VerifyParam SetupVerifyParameters(TestContext ctx) { switch (Parameters.VerifyParamType) { case BoringVerifyParamType.None: return(null); case BoringVerifyParamType.SslClient: return(BtlsProvider.GetVerifyParam_SslClient()); case BoringVerifyParamType.SslServer: return(BtlsProvider.GetVerifyParam_SslServer()); case BoringVerifyParamType.CopySslClient: return(BtlsProvider.GetVerifyParam_SslClient().Copy()); case BoringVerifyParamType.CopySslServer: return(BtlsProvider.GetVerifyParam_SslServer().Copy()); default: ctx.AssertFail("Unsupported VerifyParamType: '{0}'.", Parameters.VerifyParamType); throw new InvalidOperationException(); } }
public Task Initialize(TestContext ctx, CancellationToken cancellationToken) { return(Task.Run(() => { x509 = BtlsProvider.CreateNative(data, format); })); }
static BtlsX509 ReadFromFile(string filename) { var data = File.ReadAllBytes(filename); return(BtlsProvider.CreateNative(data, BtlsX509Format.PEM)); }