Trouble with X509 authentication

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default Trouble with X509 authentication

    Hi all,


    I'm trying to get the hang of WSE2, and am running into a problem. I
    wrote a simple web service, and a simple client that calls that web
    service. If I do not have a policy in effect for the web service,
    everything works fine. When I turn the policy on, I get:

    Microsoft.Web.Services2.Policy*.PolicyVerification Exception: WSE402:
    The message does not conform to the policy it was mapped to


    Now, I *thought* I'm setting the policy right on the web service side
    and adding the security credential correctly on the client side, but I
    guess not. I'm using the sample client and server certificates that
    come with WSE2, and have "allow test roots" selected for the web
    service.


    My client code is (abbreviated):


    private X509SecurityToken GetSecurityToken()
    {
    X509SecurityToken token = null;

    X509CertificateStore store =
    X509CertificateStore.CurrentUs*erStore
    (X509CertificateStore.MyStore)*;

    string clientBase64KeyId = "gBfo0147lM6cKnTbbMSuMVvmFY4="*;

    store.Open();
    X509CertificateCollection certs =
    store.FindCertificateByKeyIden*tifier(Convert.From Base64Strin*g
    (clientBase64KeyId));
    store.Close();
    store.Dispose();

    if (certs.Count > 0)
    {
    token = new X509SecurityToken((X509Certifi*cate)certs[0]);
    }

    return token;
    }


    public override void CreditAccount(...)
    {
    WebService.BillingWse webService = new WebService.BillingWse();

    X509SecurityToken token = GetSecurityToken();

    if (token != null)
    {
    webService.RequestSoapContext.*Security.Tokens.Add (token);
    webService.RequestSoapContext.*Security.Elements.A dd(new
    MessageSignature(token));
    }
    webService.CreditAccount(...);
    }


    I think the client's certificate is entered correctly in the
    policyCache.config file (created using the WSE2 Properties wizard):

    <wsp:Policy wsu:Id="Sign-X.509">
    <!--MessagePredicate is used to require headers. This assertion
    should be used along with the Integrity assertion when the presence of
    the signed element is required. NOTE: this assertion does not do
    anything for enforcement (send-side) policy.-->
    <wsp:MessagePredicate wsp:Usage="wsp:Required"
    Dialect="http://schemas.xmlsoap.org/200*2/12/wsse#part">wsp:Body()
    wsp:Header(wsa:To) wsp:Header(wsa:Action) wsp:Header wsa:MessageID)
    wse:Timestamp()</wsp:MessagePr*edicate>
    <!--The Integrity assertion is used to ensure that the message is
    signed with X.509. Many Web services will also use the token for
    authorization, such as by using the <wse:Role> claim or specific X.509
    claims.-->
    <wssp:Integrity wsp:Usage="wsp:Required">
    <wssp:TokenInfo>
    <!--The SecurityToken element within the TokenInfo element
    describes which token type must be used for Signing.-->
    <wssp:SecurityToken>


    <wssp:TokenType>http://docs.oasis-open.org/wss*/2004/01/oasis-200401-wss-x509*-token-pr...</wssp:TokenType>

    <wssp:TokenIssuer>CN=Root Agency</wssp:TokenIssuer>
    <wssp:Claims>
    <!--By specifying the SubjectName claim, the policy
    system can look for a certificate with this subject name in the
    certificate store indicated in the application's configuration, such as

    LocalMachine or CurrentUser. The WSE X.509 Certificate Tool is useful
    for finding the correct values for this field.-->
    <wssp:SubjectName
    MatchType="wssp:Exact">CN=WSE2*QuickStartClient</wssp:Subject*Name>
    <wssp:X509Extension OID="2.5.29.14"
    MatchType="wssp:Exact">gBfo014*7lM6cKnTbbMSuMVvmFY 4=</wssp:X5*09Extension>

    </wssp:Claims>
    </wssp:SecurityToken>
    </wssp:TokenInfo>
    <wssp:MessageParts
    Dialect="http://schemas.xmlsoap.org/200*2/12/wsse#part">wsp:Body()
    wsp:Header(wsa:Action) wsp:Header(wsa:FaultTo) wsp:Header(wsa:From)
    wsp:Header(wsa:MessageID) wsp:Header(wsa:RelatesTo)
    wsp:Header(wsa:ReplyTo) wsp:Header(wsa:To)
    wse:Timestamp()</wssp:MessageP*arts>
    </wssp:Integrity>
    </wsp:Policy>


    Anyone have any insight?


    Thanks,


    Eric

    Eric Guest

  2. Similar Questions and Discussions

    1. Net::SSH::Perl Trouble with publickey authentication
      The system is a Solaris 8 Sparc, gcc, perl 5.8.5 without an internet connection. I had to modify some perl modules and header files to get this...
    2. Webservice, SSL, X509 certificate
      Hi, i'm consuming a webservice over SSL (https) and additionally sending a X509 client-certificate. On my Win2000 Prof. workstation i installed...
    3. Keyset does not exist at Microsoft.Web.Services.Security.X509.X509
      I get this error trying to read de sign from a X509 Certficate Token X509SecurityToken.get_SignatureKey(). When I use the C# clases from windows...
    4. Referring to a X509 extension by OID
      Hi, I'm currently using OpenCA::X509 module to parse X509 certificates. However, when I use the getTXT function to display the certificate in...
    5. x509 certificates
      Hi PHP folks, Does anybody know a way to read the extension fields from a x509 certificate? Maybe there is a better PHP module than openssl....
  3. #2

    Default Re: Trouble with X509 authentication

    I solved this issue by following the steps at:

    [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;901183[/url]

    Eric Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139