示例#1
0
        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);
            }
        }
示例#2
0
 public Task Initialize(TestContext ctx, CancellationToken cancellationToken)
 {
     return(Task.Run(() => {
         store = BtlsProvider.CreateNativeStore();
         if (loadTrustedRoots)
         {
             store.AddTrustedRoots();
         }
     }));
 }
示例#3
0
        // [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());
        }