login about faq

Keep getting this error,when importing a publicKey

ChilkatLog:
ImportPublicKey:
DllDate: Aug 15 2013
ChilkatVersion: 9.4.1.42
UnlockPrefix: ANGELORSA
Username: WIN2008R2:WIN2008R2$
Architecture: Little Endian; 64-bit
Language: ActiveX / x64
VerboseLogging: 0
No modulus
Failed.
--ImportPublicKey
--ChilkatLog

My code to import the key public key

  EXEC sp_OAMethod @cert, 'LoadFromFile', @success OUT, 'c:\temp\Chave_Publica.pem'
IF @success <> 1
  BEGIN
    EXEC sp_OAGetProperty @cert, 'LastErrorText', @sTmp0 OUT

    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @privKey
    EXEC @hr = sp_OADestroy @cert
    RETURN
  END

DECLARE @pubKey int

EXEC sp_OAMethod @cert, 'ExportPublicKey', @pubKey OUT

--  Now verify using a separate instance of the RSA object:
DECLARE @rsa2 int
EXEC @hr = sp_OACreate 'Chilkat.Rsa', @rsa2 OUT
IF @hr <> 0
BEGIN
    PRINT 'Failed to create ActiveX component'
    EXEC @hr = sp_OADestroy @privKey
    EXEC @hr = sp_OADestroy @rsa2
    EXEC @hr = sp_OADestroy @cert
    RETURN
END

EXEC sp_OAMethod @rsa2, 'UnlockComponent', @success OUT, 'xxxxxxxxUxxxxxxxxxxxxxxx'
IF @success <> 1
  BEGIN
    PRINT 'RSA component unlock failed'
    EXEC @hr = sp_OADestroy @rsa2
    RETURN
  END

--  Import the public key into the RSA object:
EXEC sp_OAMethod @pubKey, 'GetXml', @sTmp0 OUT    
EXEC sp_OAMethod @rsa2, 'ImportPublicKey', @success OUT, @sTmp0
IF @success <> 1
  BEGIN
    EXEC sp_OAGetProperty @rsa2, 'LastErrorText', @sTmp0 OUT
    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @privKey
    EXEC @hr = sp_OADestroy @cert
    EXEC @hr = sp_OADestroy @rsa2
    RETURN
  END

asked Jan 15 '14 at 17:10

Paulo's gravatar image

Paulo
1112

edited Jan 15 '14 at 17:13


This would happen if the public key object was empty (i.e. was never loaded from a file).

Chilkat resolved this problem with the customer via email. The problem was that the call to publicKey.LoadOpenSslPem was mistakenly called instead of LoadOpenSslPemFile. The LoadOpenSslPem method is when the PEM data is passed directly, whereas the path of a file containing the PEM data is passed to LoadOpenSslPemFile.

link

answered Jan 17 '14 at 13:44

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

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:

×47
×2

Asked: Jan 15 '14 at 17:10

Seen: 1,365 times

Last updated: Jan 17 '14 at 13:44

powered by OSQA