PKCS11.ListSlots, PKCS11.ListTokens, PKCS11.ListObjects all works properly.
When try use PKCS11.ListCertificates get several random chars. The same for PKCS11.ShowCert. Certificate is quite new (2 weeks) and works with desktop application from certificate vendor.
OS: Windows 10 Home
Environment : Delphi 10.4.2
Platform : Windows 32 bit
TMS Cryptography Pack v4.3.2.5
Bernard
(Bernard)
November 20, 2023, 5:13am
2
Hi,
Can you send some code and snapshots?
Hi!
This is simple test code created after problem with sign xml document in demo app. Demo returns error "Wrong certificate (v3 required)". After debuging demo found that PKCS11 has problem reading certificate from card.
procedure TForm1.Button1Click(Sender: TObject);
var
PKCS11 : TPKCS11 ;
Slots : TStringList ;
Tokens : TStringList ;
Objects : TStringList ;
Certs : TStringList ;
CertImg : TStringList ;
begin
PKCS11 := TPKCS11.Create('c:\Program Files (x86)\Certum\SimplySign Desktop\proCertum SmartSign\cryptoCertum3PKCS.dll') ;
try
Slots := PKCS11.ListSlots ;
MemoSlots.Text := Slots.Text ;
PKCS11.currentSlotIndex := 0 ;
Tokens := PKCS11.ListTokens ;
MemoTokens.Text := Tokens.Text ;
Objects := PKCS11.ListObjects ;
MemoObjects.Text := Objects.Text ;
PKCS11.currentObjectIndex := 10 ;
Certs := PKCS11.ListCertificates ;
MemoCerts.Text := Certs.Text ;
CertImg := PKCS11.ShowCert(10) ;
MemoCertImg.Text := CertImg.Text ;
finally
PKCS11.Free ;
end ; { try .. finally }
end ;
Some additional info:
Certificate created for polish owner (Midle-East Europe, national chars).
Cryptography Pack upgraded to 4.3.3.0. After this PKCS11.DLLpath property. stop working. Path to DLL must specify in Create.
Desktop application in 32-but version so DLL too.
Form1.pdf (54.0 KB)
Bernard
(Bernard)
November 20, 2023, 12:36pm
4
The last line of the cert text could be some hexadecimal string. Can you convert it with functions in MiscObj.pas?
Hi!
I don't know if it is You want?
I made:
CertImg.SaveToFile('aqq.txt') ;
and view this file in TotalCommander lister as HEX.
Bernard
(Bernard)
November 20, 2023, 3:03pm
6
Most likely. I was interested in the sequence starting on the 3rd line with 07 E4 1D 06...
Unfortunately, it doesn't look like an ASN.1 sequence (usually starting with 30...).
I need to investigate with my own certificate.
Bernard
(Bernard)
November 20, 2023, 3:51pm
8
Did you try the demo with "Generate AdES" and the following parameters?
PAdES
Path to your PKCS DLL
PIN code
Enveloped
Any PDF file to sign
Any name for the signed file
It works fine with my USB token that is Version X.509 V3.
Bernard
(Bernard)
November 20, 2023, 4:11pm
10
Can you take a snapshot like this one?
I don't need the serial number.
Hi!
Wersja : V3
Algorytm podpisu: sha256RSA
Algorytm wyznaczania skrótu podpisu: sha256
Wystawca: 2.5.4.97 = VATPL-5170359458
CN = Certum QCA 2017
O = Asseco Data Systems S.A.
C = PL
Ważny od: wtorek, 31 października 2023 09:44:55
Ważny do: piątek, 30 października 2026 09:44:55
Podmiot: C = PL
SERIALNUMBER = XXXXX-999999999999
SN = Dziurman
G = Stanisław
CN = Stanisław Dziurman
Klucz publiczny: RSA(3072Bits)
Bernard
(Bernard)
November 20, 2023, 5:14pm
12
Looks very good.
The only difference is the key size (3072). I need to check whether this can be the cause of the problem.
Bernard
(Bernard)
November 21, 2023, 10:18am
13
Hi, the 'garbage' is actually the PKCS label that shows below the PKCS identifier un your cert app.
It looks like this on mine:
e79fbf50-aead...
Can you check yours? It could look like 07e41d06-14616fc7-...
Bernard
(Bernard)
November 21, 2023, 10:58am
14
Running your code (tweaked), I get this:
Bernard
(Bernard)
November 21, 2023, 12:26pm
16
You should have an app in your widget toolbar (arrow icon close to the wifi icon at the bottom) that can read what is in your USB token. The icon of mine looks like a chip.
Hi!
I have only CardManager but it not show so detailed info.
Bernard
(Bernard)
November 21, 2023, 9:03pm
18
Can you add this to your code:
MyString := PKCS11.ExtractCertificate(10);
ContentMemo.Lines.Add(MyString);
and send me the Base64 value in ContentMemo (you need to add a TMemo on the GUI)?
Hi!
I have certificate in *.pem file. Content is the same as returned by Your code.
Stanisław Dziurman.zip (1.9 KB)
Additionally content from Your code.
cert.zip (1.8 KB)
Bernard
(Bernard)
November 22, 2023, 12:47pm
20
Thanks, it is a version 3 certificate that decodes well.
The issue is with the parser code that gets a value from an incorrect index and then raises an error on the version.
I will fix this but it won't fix the 'garbage' from the cert ID string.