mguessan / davmail

DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange and Office 365 Gateway - Synced with main subversion repository at
http://davmail.sourceforge.net
GNU General Public License v2.0
573 stars 84 forks source link

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

Open esabol opened 2 years ago

esabol commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

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!