Archived Forum Post

Index of archived forum posts

Question:

LoadPkcs8Encrypted instead of LoadPkcs8EncryptedFile method in "privateKey" class

Feb 02 '14 at 03:16

I want to use LoadPkcs8Encrypted instead of LoadPkcs8EncryptedFile method in a "privateKey" class, up to now first I am getting/reading each byte of the "Encypted File" into a string varible (my_KEYstr), and then, I use this string variable as the parameter to the LoadPkcs8Encrypted, but It fails.


Example of "fail" on LoadPkcs8EncryptedFile:

Public Function get_keyPEMstr(ByVal my_KEYstr As String, ByVal keyPassword As String, _ Optional ByRef errDescripcion As String) As String

Dim privKey As privateKey 'chilkatcert.dll

Dim success As Long

Set privKey = New privateKey

Let success = privKey.LoadPkcs8Encrypted(my_KEYstr, keyPassword) ' ERROR!

If (success <> 1) Then Let errDescripcion = privKey.LastErrorText Set privKey = Nothing Exit Function End If

Let get_keyPEMstr = privKey.GetRsaPem

Set privKey = Nothing

End Function


By the other hand, if I use LoadPkcs8EncryptedFile, I do not get the error and result is good:


Example of success on LoadPkcs8EncryptedFile:

Public Function get_keyPEMstrFromKEYfile(ByVal PathFileNameKey As String, ByVal keyPassword As String, _ Optional ByRef errDescripcion As String) As String

Dim privKey As privateKey 'chilkatcert.dll

Dim success As Long

Set privKey = New privateKey

Let success = privKey.LoadPkcs8EncryptedFile(PathFileNameKey, keyPassword)

If (success <> 1) Then Let errDescripcion = privKey.LastErrorText

Set privKey = Nothing

Exit Function

End If

Let get_keyPEMstrFromKEYfile = privKey.GetRsaPem

Set privKey = Nothing

End Function


Does anybody know what is the condition to be meet by the string variable "my_KEYstr" in order to be accepted by the LoadPkcs8Encrypted method?