예제 #1
0
        public void NewTsViaEHealth()
        {
            //Read this to enable TLS1.2 on old .Net Framework:
            //https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls#configuring-security-via-the-windows-registry

            var certs = new EHealthP12(@"EHealthP12/eHealth.acc-p12", File.ReadAllText(@"EHealthP12/eHealth.acc-p12.pwd"));

            var tsa = new TimeStampAuthorityClient(new StsBinding(), new EndpointAddress(new Uri("https://services-acpt.ehealth.fgov.be/TimestampAuthority/v2")));

            tsa.ClientCredentials.ClientCertificate.Certificate = certs["authentication"];

            var provider = new EHealthTimestampProvider(tsa);

            byte[] tsBytes = provider.GetTimestampFromDocumentHash(hash, "http://www.w3.org/2001/04/xmlenc#sha256");
            File.WriteAllBytes(@"files/eHTs2.ts", tsBytes);

            TimeStampToken tst = tsBytes.ToTimeStampToken();

            Assert.True(tst.IsMatch(new MemoryStream(msg)));

            IList <CertificateList>   crls = new List <CertificateList>();
            IList <BasicOcspResponse> ocps = new List <BasicOcspResponse>();

            tst.Validate(crls, ocps);
            tst.Validate(crls, ocps, null);
        }
예제 #2
0
        public EHIntegrationTest()
        {
            ECDSAConfig.Init(); //needed to enable ECDSA globally.

            wstEp = new EndpointAddress("https://services-int.ehealth.fgov.be/IAM/SecurityTokenService/v1");
            //wstEp = new EndpointAddress("https://services-acpt.ehealth.fgov.be/IAM/SecurityTokenService/v1");

            samlpEp = new EndpointAddress("https://services-int.ehealth.fgov.be/IAM/Saml11TokenService/v1");
            //samlpEp = new EndpointAddress("https://services-acpt.ehealth.fgov.be/IAM/Saml11TokenService/v1");

            var p12 = new EHealthP12("files/ehealth-01050399864-int.p12", File.ReadAllText("files/ehealth-01050399864-int.p12.pwd"));

            //var p12 = new EHealthP12("files/ehealth-79021802145-acc.p12", File.ReadAllText("files/ehealth-79021802145-acc.p12.pwd"));
            session = p12["authentication"];

            issuer = new X509Certificate2("files/IAMINT.cer");
            //issuer = new X509Certificate2("files/IAMACC.cer");

            binding = new StsBinding()
            {
                BypassProxyOnLocal = false,
                UseDefaultWebProxy = false,
                ProxyAddress       = new Uri("http://localhost:8080")
            };
        }
예제 #3
0
        public static void InitializeClass(TestContext ctx)
        {
            //Load eHealth certificates
            alice = new EHealthP12(GetAbsoluteTestFilePath("alice/alices_private_key_store.p12"), "test");
            bob   = new EHealthP12(GetAbsoluteTestFilePath("bob/bobs_private_key_store.p12"), "test");

            AsymmetricAlgorithm key = RSA.Create();
            String keyID            = "myid";
        }
예제 #4
0
        public void MyClassInitialize(TestContext ctx)
        {
            var alice = new EHealthP12(GetAbsoluteTestFilePath("alice/old_alices_private_key_store.p12"), "test");
            var bob   = new EHealthP12(GetAbsoluteTestFilePath("bob/old_bobs_private_key_store.p12"), "test");


            aliceSealer  = EhDataSealerFactory.Create(Level.B_Level, alice);
            bobUnsealer  = DataUnsealerFactory.Create(null, bob);
            anonUnsealer = DataUnsealerFactory.Create(null);
        }
예제 #5
0
        public static void InitializeClass(TestContext ctx)
        {
            //Bob as decryption
            bobEtk = new EncryptionToken(Utils.ReadFully("bob/bobs_public_key.etk"));

            //Bob (and Alice) used for decryption
            alice = new EHealthP12("alice/alices_private_key_store.p12", "test");
            bob   = new EHealthP12("bob/bobs_private_key_store.p12", "test");

            //create a tsa (fedict in this case)
            tsa = new Rfc3161TimestampProvider();
        }
예제 #6
0
        public static void InitializeClass(TestContext ctx)
        {
            //sign with generated key
            key = new WebKey(RSA.Create());

            //Bob as decryption
            bobEtk = new EncryptionToken(File.ReadAllBytes("bob/bobs_public_key.etk"));

            //Bob (and Alice) used for decryption
            alice = new EHealthP12("alice/alices_private_key_store.p12", "test");
            bob   = new EHealthP12("bob/bobs_private_key_store.p12", "test");

            //create a tsa (fedict in this case)
            tsa = new Rfc3161TimestampProvider();
        }
예제 #7
0
        IDataSealer Create(Level level, EHealthP12 p12)
        {
            if ((level & Level.T_Level) == Level.T_Level)
            {
                throw new NotSupportedException("This method can't create timestamps");
            }

            X509Certificate2 cert = p12["authentication"];

            return(new TripleWrapper(
#if !NETFRAMEWORK
                       _loggerFactory,
#endif
                       level, cert, cert, null, p12.ToCollection()));
        }
예제 #8
0
        IDataSealer CreateForTimemarkAuthority(Level level, EHealthP12 p12)
        {
            if ((level & Level.T_Level) != Level.T_Level)
            {
                throw new ArgumentException("This method should for a level that requires time marking");
            }

            X509Certificate2 cert = p12["authentication"];

            return(new TripleWrapper(
#if !NETFRAMEWORK
                       _loggerFactory,
#endif
                       level, cert, cert, null, p12.ToCollection()));
        }
예제 #9
0
        public XadesTest()
        {
            var ehP12 = new EHealthP12(@"data\MYCARENET.p12", File.ReadAllText(@"data\MYCARENET.pwd"));

            auth       = ehP12["authentication"];
            sign       = ehP12["authentication"];
            extraCerts = ehP12.ToCollection();

            //load test document as xml
            document = new XmlDocument();
            document.PreserveWhitespace = true;
            document.Load(@"data\document.xml");


            //create the tsa
            tsa = new TimeStampAuthorityClient(new StsBinding(), new EndpointAddress("https://services-acpt.ehealth.fgov.be/TimestampAuthority/v2"));
            tsa.ClientCredentials.ClientCertificate.Certificate = auth;
        }
예제 #10
0
        IDataSealer Create(Level level, ITimestampProvider timestampProvider, EHealthP12 p12)
        {
            if (timestampProvider == null)
            {
                throw new ArgumentNullException("timestampProvider", "A time-stamp provider is required with this method");
            }
            if ((level & Level.T_Level) != Level.T_Level)
            {
                throw new ArgumentException("This method should for a level that requires time stamping");
            }

            X509Certificate2 cert = p12["authentication"];

            return(new TripleWrapper(
#if !NETFRAMEWORK
                       _loggerFactory,
#endif
                       level, cert, cert, timestampProvider, p12.ToCollection()));
        }
예제 #11
0
 public void MyClassInitialize(TestContext ctx)
 {
     bob   = new EHealthP12(GetAbsoluteTestFilePath("bob/bobs_private_key_store.p12"), "test");
     alice = new EHealthP12(GetAbsoluteTestFilePath("alice/alices_private_key_store.p12"), "test");
     //mcn = new EHealthP12(GetAbsoluteTestFilePath("mcn/MYCARENET.p12"), File.ReadAllText(GetAbsoluteTestFilePath("mcn/MYCARENET.pwd")));
 }
예제 #12
0
 public void setup()
 {
     p12 = new EHealthP12(@"..\..\EHealthP12\dummy.p12", "test001");
 }
예제 #13
0
 public void ConstuctorWithByteArray()
 {
     p12 = new EHealthP12(File.ReadAllBytes(@"..\..\EHealthP12\dummy.p12"), "test001");
     Assert.AreEqual(5, p12.Keys.Count);
 }
예제 #14
0
        public static void InitializeClass()
        {
            //Bob as decryption
            bobEtk = new EncryptionToken(Utils.ReadFully("../../bob/bobs_public_key.etk"));

            //Bob (and Alice) used for decryption
            alice = new EHealthP12("../../alice/alices_private_key_store.p12", "test");
            bob = new EHealthP12("../../bob/bobs_private_key_store.p12", "test");

            //create a tsa (fedict in this case)
            tsa = new Rfc3161TimestampProvider();
        }
예제 #15
0
 public void ConstuctorWithByteArray()
 {
     p12 = new EHealthP12(File.ReadAllBytes(@"EHealthP12/dummy.p12"), "test001");
     Assert.AreEqual(5, p12.Keys.Count);
 }
예제 #16
0
파일: Alice.cs 프로젝트: svn2github/etee
 public static void InitializeClass()
 {
     //Load eHealth certificates
     alice = new EHealthP12("../../alice/alices_private_key_store.p12", "test");
     bob = new EHealthP12("../../bob/bobs_private_key_store.p12", "test");
 }
예제 #17
0
        public static IDataSealer CreateForTimemarkAuthority(Level level, EHealthP12 p12)
        {
            ValidateCertificates(p12["authentication"]);
            if ((level & Level.T_Level) != Level.T_Level) throw new ArgumentException("This method should for a level that requires time marking");

            return new TripleWrapper(level, p12["authentication"], null, null, p12.ToCollection());
        }
예제 #18
0
 public EHealthP12Tests()
 {
     dummyP12 = new EHealthP12(@"EHealthP12/dummy.p12", "test001");
     realP12  = new EHealthP12(@"EHealthP12\eHealth.acc-p12", File.ReadAllText(@"EHealthP12\eHealth.acc-p12.pwd"));
 }
예제 #19
0
        public static IDataSealer Create(Level level, EHealthP12 p12)
        {
            ValidateCertificates(p12["authentication"]);
            if ((level & Level.T_Level) == Level.T_Level) throw new NotSupportedException("This method can't create timestamps");

            return new TripleWrapper(level, p12["authentication"], null, null, p12.ToCollection());
        }
예제 #20
0
 public static void setup(TestContext ctx)
 {
     p12 = new EHealthP12(@"EHealthP12\eHealth.acc-p12", File.ReadAllText(@"EHealthP12\eHealth.acc-p12.pwd"));
 }
예제 #21
0
        public void MyClassInitialize()
        {
            var alice = new EHealthP12("../../alice/old_alices_private_key_store.p12", "test");
            var bob = new EHealthP12("../../bob/old_bobs_private_key_store.p12", "test");

            aliceSealer = EhDataSealerFactory.Create(Level.B_Level, alice);
            bobUnsealer = DataUnsealerFactory.Create(null, bob);
            anonUnsealer = DataUnsealerFactory.Create(null);
        }
예제 #22
0
 public static void setup()
 {
     p12 = new EHealthP12(@"..\..\EHealthP12\SSIN=79021802145.p12", File.ReadAllText(@"..\..\EHealthP12\SSIN=79021802145.txt"));
     //p12 = new EHealthP12(@"..\..\EHealthP12\ehealth.p12", File.ReadAllText(@"..\..\EHealthP12\ehealth.txt"));
 }
예제 #23
0
 public static void setupClass(TestContext ctx)
 {
     p12 = new EHealthP12(@"EHealthP12/dummy.p12", "test001");
 }
예제 #24
0
        public static IDataSealer Create(Level level, ITimestampProvider timestampProvider, EHealthP12 p12)
        {
            ValidateCertificates(p12["authentication"]);
            if (timestampProvider == null) throw new ArgumentNullException("timestampProvider", "A time-stamp provider is required with this method");
            if ((level & Level.T_Level) != Level.T_Level) throw new ArgumentException("This method should for a level that requires time stamping");

            return new TripleWrapper(level, p12["authentication"], null, timestampProvider, p12.ToCollection());
        }
예제 #25
0
 public void MyClassInitialize(TestContext ctx)
 {
     bob = new EHealthP12(GetAbsoluteTestFilePath("bob/bobs_private_key_store.p12"), "test");
 }