Hi,
I'm using CAPICOM 2.0.0.3 for signing in a web app. I'm having an error
during the signing process
with some certificates. Some others works fine.

The error occurs in this line:
"Message = SignedData.Sign(Signer, TRUE)" in the "signCapi" function

The error that appeared in a message box after having selected his
certificate is the following:

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

I think this code in this error code page for CAPICOM
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/seccrypto/security/capicom_error_code.asp
)

correspond to this:
---------------------------------
= 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.
---------------------------------


Some of the code is:
------------------------------------------------------
Const CAPICOM_URL =
"http://www.microsoft.com/downloads/release.asp?ReleaseID=44155"
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

------------------------------------------------------

Thanks!