Beispiel #1
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());
        }
Beispiel #2
0
        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();
            }
        }