Ejemplo n.º 1
0
        /// <summary>
        /// Digitally signs the AS4Message using the given <paramref name="signatureConfiguration"/>
        /// </summary>
        /// <param name="signatureConfiguration"></param>
        public void Sign(CalculateSignatureConfig signatureConfiguration)
        {
            if (signatureConfiguration == null)
            {
                throw new ArgumentNullException(nameof(signatureConfiguration));
            }

            SignStrategy signingStrategy = SignStrategy.ForAS4Message(this, signatureConfiguration);

            SecurityHeader.Sign(signingStrategy);
        }
        private static SignStrategy CreateSignStrategyForSigning()
        {
            var        signingId  = new SigningId("header-id", "body-id");
            AS4Message as4Message = AS4Message.Empty;

            as4Message.SigningId = signingId;

            var signingConfig = new CalculateSignatureConfig(new StubCertificateRepository().GetStubCertificate(),
                                                             X509ReferenceType.BSTReference, Constants.SignAlgorithms.Sha256, Constants.HashFunctions.Sha256);

            return(SignStrategy.ForAS4Message(as4Message, signingConfig));
        }
Ejemplo n.º 3
0
        private static AS4Message SignAS4MessageWithPullRequestCert(AS4Message message)
        {
            var certificate =
                new X509Certificate2(
                    @".\samples\certificates\AccessPointA.pfx",
                    "Pz4cZK4SULUwmraZa",
                    X509KeyStorageFlags.Exportable);

            var config = new CalculateSignatureConfig(certificate,
                                                      X509ReferenceType.BSTReference,
                                                      Constants.SignAlgorithms.Sha256,
                                                      Constants.HashFunctions.Sha256);

            message.SecurityHeader.Sign(
                SignStrategy.ForAS4Message(message, config));

            return(message);
        }