How to sign both Timestamp AND Body in a Soap 1.1 envelope with WCF RRS feed

  • Question

  • Hi

    I am consuming a WS that requires the request to be signed but not encrypted.

    I think (from what i understand) that i am signing the timestamp only in the envelope below. I want to sign both the Timestamp AND the Body. How do i go about doing this?

    Here is what i get for an envelope:

    <s:Envelope xmlns:s="" xmlns:u="">
        <o:Security s:mustUnderstand="1" xmlns:o="">
          <u:Timestamp u:Id="_0">
          <o:BinarySecurityToken u:Id="uuid-e02563d0-3a94-42e0-8730-d25accfcb3ad-1" ValueType="" EncodingType="">MIIEyjCCA7KgA <!-- REMOVED -->n6uOrzSPBhsCS+PHZ0</o:BinarySecurityToken>
          <Signature xmlns="">
              <CanonicalizationMethod Algorithm=""/>
              <SignatureMethod Algorithm=""/>
              <Reference URI="#_0">
                  <Transform Algorithm=""/>
                <DigestMethod Algorithm=""/>
                <o:Reference ValueType="" URI="#uuid-e02563d0-3a94-42e0-8730-d25accfcb3ad-1"/>
      <s:Body xmlns:xsi="" xmlns:xsd="">
        <HentHelseindikasjonRequest xmlns="">

    Here is my code. This is just a small testapplication, and i know it does not look good. I just want to make it work, then i will make it look a bit better :)

    ServiceReference1.KjernejournalClient proxy = new ServiceReference1.KjernejournalClient();                
    ServiceReference1.HentHelseindikasjonRequestType request = new ServiceReference1.HentHelseindikasjonRequestType();
    var vs = proxy.Endpoint.Behaviors.Where((i) => i.GetType().Namespace.Contains("VisualStudio"));
    request.Fnr = txtFodselsnummer.Text;
    proxy.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(@"\\\Biztalkt\Certificates\883974832\Private\Nonrep\Buypass ID-ST OLAVS HOSPITAL HF-serienummer547829953466922088190048-2013-04-16.p12", strCertPwd);
    proxy.Endpoint.Contract.Operations[0].Messages[0].ProtectionLevel = System.Net.Security.ProtectionLevel.Sign;
    ServiceReference1.HentHelseindikasjonResponseType response = proxy.HentHelseindikasjon(request);

    And here is my app.config:

    <?xml version="1.0"?>
            <binding  name="sslSignedEnvelope"  >
              <security authenticationMode="CertificateOverTransport" messageSecurityVersion="WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10" >
                <secureConversationBootstrap />
              <textMessageEncoding messageVersion="Soap11">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              <httpsTransport  authenticationScheme="Anonymous" maxReceivedMessageSize="2147483647" maxBufferPoolSize="524288"  />
          <endpoint address="https://endpoint/url"
            binding="customBinding" bindingConfiguration="sslSignedEnvelope"
            contract="ServiceReference1.Kjernejournal" name="Kjernejournal" />
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

    Help would really be appreciated.


    John Viggo

    • Edited by johnviggo Wednesday, May 29, 2013 11:23 AM
    Wednesday, May 29, 2013 6:39 AM


All replies

  • After scratching my head even more i now maybe see that i infact have not made a signatura for the body, but only the timestamp? Can this be right? If so. What do i need to do to sign both the Timestamp and the Body?

    (updated the question with the new information)

    • Edited by johnviggo Wednesday, May 29, 2013 9:29 AM
    Wednesday, May 29, 2013 9:07 AM
  • Hi,

    If you are using a binding that applies security at the transport level, all application data will be secured according to the capabilities of the transport.

    You can consider using a binding that applies security at the message level, then application data will be secured according to the protection levels set on the contract.

    Please check to get detail information of the protection level feature.

    Best Regards.

    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, May 30, 2013 7:06 AM