Groups | Blog | Home
all groups > dotnet web services enhancements > august 2004 >

dotnet web services enhancements : Signing the part of the message


Alex Shirshov
8/17/2004 7:58:33 PM
Hello, All!

I have a problem with signing the part of the soap body via wse 2.0. Here is
the code
[code]
Sub Main()
Dim g As New localhost.gWse()

Dim reqCtx As SoapContext = g.RequestSoapContext
Dim tok As New Tokens.UsernameToken(Environment.UserDomainName & "\"
& Environment.UserName, _
"bla-bla-bla", Tokens.PasswordOption.SendHashed)
reqCtx.Security.Tokens.Add(tok)

Dim guid As Guid = guid.NewGuid()
Dim d As New localhost.Dummy
d.Id = "Id:" & guid.ToString
d._a = 180

Dim sg As New MessageSignature(tok)
'sg.SignatureOptions = SignatureOptions.IncludeNone
sg.SignedInfo.AddReference(New SignatureReference("#" & d.Id))

reqCtx.Security.Elements.Add(sg)

g.SignedMessage(d)
Console.ReadLine()
End Sub
[/code]

This is a Dummy class
[code]
'<remarks/>

<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="some-namespace")>
_
Public Class Dummy

'<remarks/>
Public _a As Integer

'<remarks/>

<System.Xml.Serialization.XmlAttributeAttribute([Namespace]:="http://docs.oa
sis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xs" & _
"d")> _
Public Id As String
End Class
[/code]

Whan I call SignedMessage method it throws an exception:
[exception]
An unhandled exception of type
'System.Security.Cryptography.CryptographicException' occurred in
microsoft.web.services2.dll

Additional information: Transform chain is empty
[/exception]

This is client side exception - server side does not receive soap envelope.
Without signing (in other words without adding MessageSignature to the
security elements) or with signing entire soap body I have no problems - all
ok.

What am i doing wrong.

With best regards, Alex Shirshov.

Sidd
8/19/2004 5:31:44 PM
Hi Alex,

There was a change made in WSE 2.0. Now you would have to go about it
like:

SignatureReference r = new SignatureReference("#" + d.Id);
r.AddTransform(new
Microsoft.Web.Services2.Security.Xml.XmlDsigExcC14NTransform()) -->
this is the line you were missing
sg.AddReference(r);

(NOTE: you could also do what you do below:
sg.SignedInfo.AddReference(...) --- they both work :)

Apologies for the C# syntax above.

Thanks. Let me know if this helps or not.

Sidd


[quoted text, click to view]

Alex Shirshov
8/20/2004 3:14:31 PM
Hello, Sidd!
You wrote on Thu, 19 Aug 2004 17:31:44 -0700:


[Sorry, skipped]

S> Apologies for the C# syntax above.

Never mind. :)

S> Thanks. Let me know if this helps or not.

Thank you very much. It completely helps.

With best regards, Alex Shirshov.

AddThis Social Bookmark Button