davmail icon indicating copy to clipboard operation
davmail copied to clipboard

java.lang.RuntimeException: Unable to configure SunPKCS11 provider Initialization failed slotListIndex is 0 but token only has 0 slots

Open esabol opened this issue 3 years ago • 3 comments

Hi. I had DavMail 6.0.1 running fine on RHEL 7.x. My sys admins upgraded my Linux box to RHEL 8.6 (actually Oracle Linux 8.6 but basically identical), and now DavMail isn't working. The log shows this:

WARN  [ImapConnection-60182] davmail  - DavMail configuration exception:
Connect exception: java.lang.RuntimeException Unable to configure SunPKCS11 provider Initialization failed slotListIndex is 0 but token only has 0 slots

Any ideas on how to fix this? Thank you for all your work on DavMail. It's a lifesaver.

esabol avatar Aug 04 '22 20:08 esabol

I should have added that I'm using O365Manual mode where you copy a URL and paste it in your web browser in order to authenticate with a card reader.

esabol avatar Aug 11 '22 21:08 esabol

After almost 2 months of banging my head on this and not seeing emails sent to me in a timely fashion, I finally found a solution (or a workaround)!

All it required was changing

davmail.ssl.pkcs11Library=/usr/lib64/pkcs11/opensc-pkcs11.so

to

davmail.ssl.pkcs11Library=/usr/lib64/pkcs11/gnome-keyring-pkcs11.so

in my ~/.davmail.properties file.

I came across a completely-unrelated-to-DavMail posting somewhere which recommended switching from opensc-pkcs11.so to gnome-keyring-pkcs11.so for something else, so I thought I'd give it a try. I'm so very happy to discover that it worked for DavMail!

I suspect DavMail could catch and ignore the "Unable to configure SunPKCS11 provider Initialization failed slotListIndex is 0 but token only has 0 slots" exception when using O365Manual mode, but I don't know really.

esabol avatar Oct 01 '22 22:10 esabol

In case anyone else is ever in a similar situation, I've discovered that

davmail.ssl.pkcs11Library=/usr/lib64/pkcs11/p11-kit-trust.so

also works. Essentially, you need the command:

p11tool --provider /usr/lib64/pkcs11/<<SOME .so file>> --list-tokens

to give you some kind of output. Try all the .so files in /usr/lib64/pkcs11/ until you find one that works!

esabol avatar Nov 18 '22 02:11 esabol