Hi Josef,
First of all, thank you for your feedback.Yes, I used it as you mentioned. I was able to get an output like this.
root@debian:~# pkcs11-tool --module /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so --list-slots
Available slots:
Slot 0 (0x0): ACS ACR39U ICC Reader 00 00
(empty)
Apart from these, when I try the codes mentioned in other topics, I get this output.
root@debian:~/jsignpdf-2.3.0-SNAPSHOT# java -Djava.security.debug=pkcs11keystore -Djava.security.debug=sunpkcs11 -jar J SignPdf.jar
SunPKCS11 loading /root/jsignpdf-2.3.0-SNAPSHOT/conf/pkcs11.cfg
sunpkcs11: Initializing PKCS#11 library /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so
Information for provider SunPKCS11-OpenSC
Library info:
cryptokiVersion: 2.20
manufacturerID: OpenSC Project
flags: 0
libraryDescription: OpenSC smartcard framework
libraryVersion: 0.19
All slots: 0
Slots with tokens: 0
FINE Relaxing SSL security.
FINE Registering SunPKCS11 provider from configuration in conf/pkcs11.cfg
SunPKCS11 loading /root/jsignpdf-2.3.0-SNAPSHOT/conf/pkcs11.cfg
sunpkcs11: Initializing PKCS#11 library /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so
Information for provider SunPKCS11-OpenSC
Library info:
cryptokiVersion: 2.20
manufacturerID: OpenSC Project
flags: 0
libraryDescription: OpenSC smartcard framework
libraryVersion: 0.19
All slots: 0
Slots with tokens: 0
FINE PKCS11 provider registered with name SunPKCS11-OpenSC
JSignPKCS11 loading /root/jsignpdf-2.3.0-SNAPSHOT/conf/pkcs11.cfg
sunpkcs11: Initializing PKCS#11 library /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so
Information for provider JSignPKCS11-OpenSC
Library info:
cryptokiVersion: 2.20
manufacturerID: OpenSC Project
flags: 0
libraryDescription: OpenSC smartcard framework
libraryVersion: 0.19
All slots: 0
Slots with tokens: 0
FINE PKCS11 provider registered with name JSignPKCS11-OpenSC
Exception in thread "main" java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
at java.awt.Window.<init>(Window.java:536)
at java.awt.Frame.<init>(Frame.java:420)
at java.awt.Frame.<init>(Frame.java:385)
at javax.swing.JFrame.<init>(JFrame.java:189)
at net.sf.jsignpdf.SignPdfForm.<init>(SignPdfForm.java:89)
at net.sf.jsignpdf.Signer.main(Signer.java:159)
Here I saw that it did not detect my inserted smart card (If I misunderstood, please correct me). Then I downloaded and installed the driver for my smart card (If you want to review it,
https://kamusm.bilgem.tubitak.gov.tr/islemler/surucu_yukleme_servis) Here I installed the Debian package for Debian buster on my system. And when I introduce the libj2pkcs11.so file provided by my driver to my site and run it, I get this output.
root@debian:~/jsignpdf-2.3.0-SNAPSHOT# java -Djava.security.debug=pkcs11keystore -Djava.security.debug=sunpkcs11 -jar JSignPdf.jar
SunPKCS11 loading /root/jsignpdf-2.3.0-SNAPSHOT/conf/pkcs11.cfg
sunpkcs11: Initializing PKCS#11 library /opt/Akia/jre/lib/libj2pkcs11.so
Exception in thread "main" java.lang.ExceptionInInitializerError
at net.sf.jsignpdf.ssl.DynamicX509TrustManager.<init>(DynamicX509TrustManager.java:70)
at net.sf.jsignpdf.ssl.SSLInitializer.<clinit>(SSLInitializer.java:64)
at net.sf.jsignpdf.Signer.main(Signer.java:99)
Caused by: java.security.ProviderException: Initialization failed
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:376)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:103)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at sun.security.jca.ProviderConfig$2.run(ProviderConfig.java:224)
at sun.security.jca.ProviderConfig$2.run(ProviderConfig.java:206)
at java.security.AccessController.doPrivileged(Native Method)
at sun.security.jca.ProviderConfig.doLoadProvider(ProviderConfig.java:206)
at sun.security.jca.ProviderConfig.getProvider(ProviderConfig.java:187)
at sun.security.jca.ProviderList.loadAll(ProviderList.java:282)
at sun.security.jca.ProviderList.removeInvalid(ProviderList.java:299)
at sun.security.jca.Providers.getFullProviderList(Providers.java:174)
at java.security.Security.insertProviderAt(Security.java:362)
at java.security.Security.addProvider(Security.java:405)
at net.sf.jsignpdf.utils.KeyStoreUtils.<clinit>(KeyStoreUtils.java:83)
... 3 more
Caused by: java.io.IOException: ERROR: C_GetFunctionList == NULL
at sun.security.pkcs11.wrapper.PKCS11.connect(Native Method)
at sun.security.pkcs11.wrapper.PKCS11.<init>(PKCS11.java:144)
at sun.security.pkcs11.wrapper.PKCS11.getInstance(PKCS11.java:157)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:313)
... 19 more
root@debian:~/jsignpdf-2.3.0-SNAPSHOT# pkcs11-tool --module /opt/Akia/jre/lib/libj2pkcs11.so --list-slots
error: Failed to load pkcs11 module
Aborting.
When I look at the Akia (smart card driver) files, I can see that security.provider.12=SunPKCS11 is defined in java security. So I tried these but I still couldn't reach a conclusion. If you have any ideas, please don't hesitate. I'm sorry for bothering you with unnecessary topics. Thanks in advance.
Regards
9 Eylül 2024 Pazartesi tarihinde saat 13:01:12 UTC+3 itibarıyla Josef Cacek şunları yazdı: