Capicom: error firmando

23/06/2005 - 21:19 por CVMolina | Informe spam
Hola,
estoy usando la CAPICOM.dll 2.0.0.3 para firmar en una app web y estoy
teniendo un error durante el proceso de firma
con algunos certificados. Otros funcionan correctamente.

El error ocurre en la linea siguiente:
"Message = SignedData.Sign(Signer, TRUE)"
en la funcion "signCapi" del codigo que adjunto.

El error que aparece en una message box luego de haber seleccionado el
certificado es el siguiente:

"VBScript -2138570157 The signer´s certificate in not valid for signing"

Creo que el codigo de error correnponde a este:

= 0x80880253 //v2.0,
CAPICOM_E_SIGN_NOT_INITIALIZED
The SignedData object has not been initialized.
To initialize the SignedData object, set the Content property or call
the Verify method.

Sacado de esta url:
http://msdn.microsoft.com/library/d...r_code.asp

Adjunto algo del codigo :

Const CAPICOM_URL =
"http://www.microsoft.com/downloads/...D155"
Const TITULO_ERROR = "Firma de Texto..."
Const TITULO_INFO = "Verificación de Firma y Certificado..."

' Constantes de la CAPICOM...
Const CAPICOM_MEMORY_STORE = 0
Const CAPICOM_LOCAL_MACHINE_STORE = 1
Const CAPICOM_CURRENT_USER_STORE = 2
Const CAPICOM_MY_STORE = "MY"
Const CAPICOM_ACTIVE_DIRECTORY_USER_STORE = 3
Const CAPICOM_SMART_CARD_USER_STORE = 4
Const CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME = 0

Const CAPICOM_STORE_OPEN_READ_ONLY = 0
Const CAPICOM_STORE_OPEN_READ_WRITE = 1
Const CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED = 2
Const CAPICOM_STORE_OPEN_EXISTING_ONLY = 128
Const CAPICOM_STORE_OPEN_INCLUDE_ARCHIVED = 256
Const CAPICOM_VERIFY_SIGNATURE_AND_CERTIFICATE = 1
Const CAPICOM_ENCODE_BASE64 = 1

Dim StoreName : StoreName = "MY"
Dim Signer, SignedData, Certificate, Message, oConvert

Dim oStore
Dim oCertificates

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function llenarCombos
on error resume next

Set oStore = CreateObject("CAPICOM.Store")

oStore.Open CAPICOM_CURRENT_USER_STORE, CAPICOM_MY_STORE,
CAPICOM_STORE_OPEN_READ_ONLY Or CAPICOM_STORE_OPEN_EXISTING_ONLY

Set oCertificates = oStore.Certificates
Dim oCertificate

For Each oCertificate in oCertificates
If(oCertificate.HasPrivateKey()) Then

agregarOpcion(oCertificate.GetInfo(CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME))
End If
Next
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function signCapi(texto, certificado)
Set Signer = CreateObject("CAPICOM.Signer")

Signer.Certificate = oCertificates(certificado + 1)

Set oStore = Nothing
Set oCertificates = Nothing

Set SignedData = CreateObject("CAPICOM.SignedData")
Set oConvert = CreateObject("ConvertString.Convert")
SignedData.Content = oConvert.StrConvert(texto)

On Error Resume Next

Message = SignedData.Sign(Signer, TRUE)

If (Err.Number <> 0) Then
MsgBox "Error: " & CStr(Err.Number) & " " & Err.Description
End If

' Muestra la firma...
pkcs7.innerText = Message
pkcs7.style.display = ""

firmarCapi = Message
Set SignedData = Nothing
On Error GoTo 0
End Function



Muchas gracias!

Preguntas similare

Leer las respuestas

#1 mbote
25/06/2005 - 13:02 | Informe spam
Eso mejor que lo preguntes en microsoft.public.security.crypto

Saludos
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida