Message VerifyMessage(Message innerMessage)
        {
            if (innerMessage == null)
            {
                return(null);
            }

            MessageBuffer buffer = innerMessage.CreateBufferedCopy(int.MaxValue);

            ReceivedCompactSignatureHeader.VerifyMessage(
                buffer.CreateMessage(),
                this.DiscoveryInfo,
                this.ReceivedCertificatesStoreSettings);
            Console.WriteLine("Verified message {0}.", innerMessage.Headers.Action);
            return(buffer.CreateMessage());
        }
Example #2
0
        public static void VerifyMessage(
            Message innerMessage,
            ProtocolSettings discoveryInfo,
            ReceivedCertificatesStoreSettings receivedCertificatesStoreSettings)
        {
            int headerIndex = innerMessage.Headers.FindHeader(ProtocolStrings.SecurityHeaderName, discoveryInfo.DiscoveryNamespace);

            if (headerIndex < 0)
            {
                // A security header is not present, so we can't verify the validity of the message.
                throw new CompactSignatureSecurityException("The received message doesn't contain a Security header");
            }

            ReceivedCompactSignatureHeader compactSignature = new ReceivedCompactSignatureHeader(innerMessage, headerIndex, discoveryInfo);

            compactSignature.Process(receivedCertificatesStoreSettings);
        }