Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / August 2004

Tip: Looking for answers? Try searching our database.

Signing the part of the message

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex Shirshov - 17 Aug 2004 16:58 GMT
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 - 20 Aug 2004 01:31 GMT
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

> Hello, All!
>
[quoted text clipped - 38 lines]
>
>         '<remarks/>

<System.Xml.Serialization.XmlAttributeAttribute([Namespace]:="http://docs.oa
> sis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xs" & _
> "d")> _
[quoted text clipped - 19 lines]
>
> With best regards, Alex Shirshov.
Alex Shirshov - 20 Aug 2004 12:14 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.