示例#1
0
        private void CheckEncryption(Envelope envelope, Attachment attachment)
        {
            var xml         = ObjectToXml.Serialize(envelope);
            var certificate = Certificates.CreateSelfSigned();

            var expected = Copy(attachment.Stream);

            var encrypter = new EbmsEncrypter
            {
                Xml                   = xml,
                Attachments           = new [] { attachment },
                PublicKeyInAsn1Format = certificate.GetPublicKey()
            };

            encrypter.Encrypt();

            var decrypter = new EbmsDecrypter
            {
                Xml         = xml,
                Attachments = new [] { attachment },
                Certificate = certificate
            };

            decrypter.Decrypt();

            var actual = Copy(attachment.Stream);

            Assert.IsTrue(expected.SequenceEqual(actual));
        }
示例#2
0
        public As4Message Send(AccessPoint destination, As4Message message)
        {
            var encrypter = new EbmsEncrypter
            {
                Attachments           = message.Attachments,
                PublicKeyInAsn1Format = destination.Ebms.GetPublicKey(),
                Xml = message.SoapEnvelope
            };

            encrypter.Encrypt();

            var client = new As4Client
            {
                Certificate = TlsExternal
            };

            return(client.Send(destination.BusinessInbound, message));
        }