Archived Forum Post

Index of archived forum posts

Question:

Verify signature with a certificate CER in a classic asp application

Apr 14 '16 at 08:26

I need to verify the signature below with a certificate CER in a classic asp application. Would Chilkat be able to do that?

<Notification ID="Notification">
  <Type>ApplicationSubmit</Type>
  <ResourceKey>Application::05b826e4-4652-4394-b81f-18ce35fe7664</ResourceKey>
  <Endpoint>https://nhmrcomnistaruat.f1solutions.com.au/Services/V1/ApplicationInterop.svc</Endpoint>
  <InterestedParty></InterestedParty>
  <Expiry>2016-05-06T11:18:31.7000000</Expiry>
  <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    <SignedInfo>
      <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
      <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
      <Reference URI="#Notification">
        <Transforms>
          <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
          <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
        </Transforms>
        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
        <DigestValue>eSEJVV6WggnzmtL7Fig98hX5BHU=</DigestValue>
      </Reference>
    </SignedInfo>
    <SignatureValue>p6Wng8SEolEogMWYmHgf10K4QffC76VsfrkFenFdco9wBvVL6tMaCgdCqFu66AEdgvqu+JgnHllay5fjTY3duM2bYRvumiw2wGCghfOSQXFA9bLm1Vau/OtrYOqtluzLWAaJL7lG0rmsg26jSOmQQLw9ryaZ4xct0cxfMfBtfbVLvGtBfJEswgFYgZyQKfkCB+O7iojjvQDNzMz2mdD6v2PfspfYRSVK1VpiQ03A559W2OxlVTKgI9z9UrhUgxndUoB+orTjEnwI6RS3u9IaN7+E+YMYot99DnndzAibRr64uT9B3narrhpSuAdFqdzPdqudW/10GHqKHLwWwentzA==</SignatureValue>
  </Signature>
</Notification>

Answer

I've downloaded the trial but in the following code it ignores the certificate. What I'm I doing wrong?

' This CreateObject statement uses the new single-DLL ActiveX for v9.5.0
set crypt = CreateObject("Chilkat_9_5_0.Crypt2")

'  Any string argument automatically begins the 30-day trial.
success = crypt.UnlockComponent("30-day trial")
If (success <> 1) Then
    Response.Write(crypt.LastErrorText)
    Response.End
End If

set cert = CreateObject("Chilkat_9_5_0.Cert")
success = cert.LoadFromFile ("c:\chilkat\certificate.cer")
if success = 0 then
    Response.Write(cert.LastErrorText)
end if

' this doesn't seem to work.
success = crypt.SetEncryptCert(cert)
If (success <> 1) Then
    Response.Write "
" Response.Write(crypt.LastErrorText) End If crypt.HashAlgorithm = "sha1" crypt.EncodingMode = "hex" ' sXML this is set further up and contains the XML Response.Write "

" hash = crypt.HashStringENC(sXML) Response.Write("SHA1: " & hash) Response.Write "
" cert = null crypt = null xml = null