473,398 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Xml Dsign

3
Hi,
I'm trying to create signed XML document with SignedXml class. I'm using Framework 1.1 and WSE 2.0 to get certificate. I get certificate from LOCAL_MACHINE\My store but when I try get private key "oCertificado.Key.ToXmlString(True)" I get the next exception:

"An unhandled exception of type 'System.NotSupportedException'
occurred in microsoft.web.services2.dll Additional information: Export of private parameters is not supported"


Expand|Select|Wrap|Line Numbers
  1.  
  2. Protected Function ObtenerCertificado() As X509Certificate
  3.  
  4.         Dim store As X509CertificateStore
  5.  
  6.         Try
  7.  
  8.             store = X509CertificateStore.LocalMachineStore       (X509CertificateStore.MyStore)
  9.  
  10.             Dim open As Boolean = store.OpenRead()
  11.             Dim oCertif As X509Certificate
  12.             Dim oCertificado As X509Certificate
  13.  
  14.             For Each oCertif In store.Certificates
  15.  
  16.                 If InStr(oCertif.GetName, "DESARROLLO.MINHAC.AGE") <> 0 Then
  17.                     oCertificado = oCertif
  18.                 End If
  19.             Next
  20.  
  21.             Return oCertificado
  22.  
  23.         Catch ex As Exception
  24.             Me.iEstadoOperacion = Me.AYUDA
  25.             Me.sMsgCliente = ex.Message
  26.             Me.sMsgCliente = Me.sMsgCliente.Replace("'", "")
  27.         Finally
  28.             store.Close()
  29.             store = Nothing
  30.         End Try
  31.  
  32.     End Function
  33.  
  34.  Protected Function FirmarXml(ByVal oCertificado As X509Certificate, ByVal DocumentoXml As XmlDocument) As XmlElement
  35.  
  36.         Dim signedXml As New System.security.Cryptography.xml.SignedXml
  37.         Dim dataObject As New DataObject
  38.  
  39.         Try
  40.  
  41.             signedXml.SigningKey = oCertificado.Key
  42.  
  43.             Me.iEstadoOperacion = Me.AYUDA
  44.             Me.sMsgCliente = oCertificado.Key.ToXmlString(False)
  45.             Exit Function
  46.  
  47.             Dim document As New XmlDocument
  48.             Dim node As XmlNode = document.CreateNode(XmlNodeType.Element, "", "MyElement", "samples")
  49.  
  50.             node.InnerText = DocumentoXml.OuterXml.ToString
  51.             document.AppendChild(node)
  52.  
  53.             dataObject.Data = document.ChildNodes
  54.             dataObject.Id = "MyObjectId"
  55.  
  56.             signedXml.AddObject(dataObject)
  57.  
  58.             ' Creamos una referencia
  59.             Dim reference As New System.security.Cryptography.xml.Reference
  60.             reference.Uri = "#MyObjectId"
  61.  
  62.             'Añadimos la referencia.
  63.             signedXml.AddReference(reference)
  64.  
  65.             'Añadimos KeyInfo.
  66.             Dim keyInfo As New KeyInfo
  67.             keyInfo.AddClause(New RSAKeyValue(oCertificado.Key))
  68.             keyInfo.AddClause(New KeyInfoX509Data(oCertificado))
  69.             signedXml.KeyInfo = keyInfo
  70.  
  71.             'Firmamos
  72.             signedXml.ComputeSignature()
  73.  
  74.             Return signedXml.GetXml()
  75.  
  76.         Catch ex As Exception
  77.             Me.iEstadoOperacion = Me.AYUDA
  78.             Me.sMsgCliente = ex.Message
  79.             Me.sMsgCliente = Me.sMsgCliente.Replace("'", "")
  80.         Finally
  81.             dataObject = Nothing
  82.             signedXml = Nothing
  83.         End Try
  84.  
  85.     End Function
Somebody know why is this exception?

Thank you very much.
Sep 17 '07 #1
2 1584
kenobewan
4,871 Expert 4TB
Does it give you a line number? Thanks.
Sep 17 '07 #2
Alf
3
Yes the exception is in line 43,
"Me.sMsgCliente = oCertificado.Key.ToXmlString(True)"

Thanks.
Sep 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Arun | last post by:
Hi..I am arun and Thanks to all of you in advance for solving my problem... I am working as a quality co-op for Maytag and I have developed a defect tracking database using access and VBA. It...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.