login about faq

I am trying to Sign a SAML assertion. For that reason I need to Sign some XML string with sha1 and using a x509 certificate. I am using a self signed certificate for now. But I am a little confused about how to do so. I tried the following Foxpro code but get the error "Does not support a collection" when trying to assign a value to HashAlgorithm.

Could you please advice if I am doing the right steps? Thanks.

*- Sample VFP source code

close all

clear all

clear

TEXT TO l_CertPrivateKey NOSHOW

-----BEGIN PRIVATE KEY-----

-----END PRIVATE KEY-----

ENDTEXT

TEXT TO l_CertPublic NOSHOW

-----BEGIN CERTIFICATE-----

-----END CERTIFICATE-----

ENDTEXT

l_o_Chilkat_PrivateKey = CreateObject('Chilkat_9_5_0.PrivateKey')

l_o_Chilkat_Crypt2 = CreateObject('Chilkat_9_5_0.Crypt2')

l_o_Chilkat_Crypt2.UnlockComponent("Start my 30-day Trial")

l_o_Chilkat_Cert = CreateObject('Chilkat_9_5_0.Cert')

lnSuccess = l_o_Chilkat_PrivateKey.LoadPem(l_CertPrivateKey)

IF (lnSuccess <> 1) THEN

? "Failed l_o_Chilkat_PrivateKey.LoadPem",l_o_Chilkat_PrivateKey.LastErrorText

RELEASE l_o_Chilkat_PrivateKey

CANCEL

ENDIF

lnSuccess = l_o_Chilkat_Cert.LoadPem(l_CertPublic)

IF (lnSuccess <> 1) THEN

? "Failed l_o_Chilkat_Cert.LoadPem", l_o_Chilkat_Cert.LastErrorText

RELEASE l_o_Chilkat

CANCEL

ENDIF

lnSuccess = l_o_Chilkat_Cert.SetPrivateKey(l_o_Chilkat_PrivateKey)

IF (lnSuccess <> 1) THEN

? "Failed l_o_Chilkat_Cert.SetPrivateKey", l_o_Chilkat_Cert.LastErrorText

RELEASE l_o_Chilkat

CANCEL

ENDIF

lnSuccess = l_o_Chilkat_Crypt2.SetSigningCert(l_o_Chilkat_Cert)

IF (lnSuccess <> 1) THEN

? "Failed l_o_Chilkat_Crypt2.SetSigningCert", l_o_Chilkat_Crypt2.LastErrorText

RELEASE l_o_Chilkat

CANCEL

ENDIF

l_o_Chilkat_Crypt2.HashAlgorithm("sha1")

?l_o_Chilkat_Crypt2.SignStringENC("hello")

return

asked Apr 11 at 05:38

Eric2016's gravatar image

Eric2016
1


HashAlgorithm is a property, not a method. Setting it to "sha1" should look like this:

l_o_Chilkat_Crypt2.HashAlgorithm = "sha1"

link

answered Apr 11 at 10:04

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Thanks. Can't believe I made such a simple mistake :)

link

answered Apr 11 at 11:45

Eric2016's gravatar image

Eric2016
1

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×18
×7
×2

Asked: Apr 11 at 05:38

Seen: 300 times

Last updated: Apr 11 at 11:45

powered by OSQA