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 / .NET Framework / Security / December 2006

Tip: Looking for answers? Try searching our database.

Validate Signed XML against X.509 Certificate in .NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
flazh2000@gmail.com - 15 Dec 2006 18:44 GMT
I'm working on the single sign on project. Does anybody know how to
validate a signed XML against X.509 certificate (public key certificate
is provided) in .NET?
I already tried using the SignXML.CheckSignature() object, but I kept
getting an invalid/false result. The CheckSignature method has no way
for me to specify which certificate to be validated against. Any web
link or sample will be very helpful. Thanks people!

The following my code. The information sent from the client is in
base64 encoding and comply to SAML specification.

=======================================================================

Dim SAMLResponse As String
Dim BC As New ASCIIEncoding
Dim DecodedData() As Byte
Dim sDecodedData As String

SAMLResponse = Request("SAMLResponse")
DecodedData = Convert.FromBase64String(SAMLResponse)
sDecodedData = BC.GetString(DecodedData)

Dim RSA As New RSACryptoServiceProvider
Dim publicKey As String

publicKey = RSA.ToXmlString(False)
RSA.FromXmlString(publicKey)

Dim xmlDocument As New XmlDocument
xmlDocument.PreserveWhitespace = True
xmlDocument.LoadXml(sDecodedData)

Dim signedXml As New SignedXml(xmlDocument)
Dim nodeList As XmlNodeList =
xmlDocument.GetElementsByTagName("ds:Signature")
signedXml.LoadXml(CType(nodeList(0), XmlElement))

If signedXml.CheckSignature(RSA) Then
   lblOutput.Text = "Valid"
Else
   lblOutput.Text = "Invalid"
End If
Eugene Mayevski - 17 Dec 2006 09:49 GMT
Hello!
You wrote  on 15 Dec 2006 10:44:32 -0800:

f> publicKey = RSA.ToXmlString(False)
f> RSA.FromXmlString(publicKey)

And where do you set the actual RSA key?
As I understand the procedure, you need to retrieve one from the certificate
that you are going to use for verification

Alternatively you can check XMLBlackbox at http://www.eldos.com/sbb/net-xml.php

With best regards,
Eugene Mayevski
http://www.SecureBlackbox.com - the comprehensive component suite for
network security

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.