Trying to use a smartcard to authenticate to Tomcat
Asked Answered
B

1

1

I have a working SSL config for my Tomcat server in my server.xml file:

<Connector port="58443" protocol="org.apache.coyote.http11.Http11NioProtocol"
    maxThreads="150" SSLEnabled="true" scheme="https" compression="2048" clientAuth="false"
    sslProtocol="TLSv1.2" URIEncoding="UTF-8" sslEnabledProtocols="TLSv1.2"
    keystoreFile="conf/keystore" keystorePass="changeit"
    ciphers="TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
    maxSwallowSize="0"/>

I want to require use of a smart card to access the server. I found Enable Tomcat server for Smart card Authentication and tried adapting the instructions to my situation. I used Windows certmgr to get the certificates for my smart card and installed them in my keystore file:

keytool -importcert -file 'My SecureBadge Basic G2.cer' -keystore ./keystore -alias rootca
keytool -importcert -file 'My Hardware Root CA.cer' -keystore ./keystore -alias serverca

My keystore now contains the following 3 entries:

rootca, Feb 18, 2019, trustedCertEntry,
Certificate fingerprint (SHA1): 2D:70:FE:85:F9:C6:7F:E8:13:9A:73:A9:A1:2D:32:24:1A:EC:EC:5B
serverca, Feb 18, 2019, trustedCertEntry,
Certificate fingerprint (SHA1): 5B:E5:34:32:FB:2B:50:1E:FB:DE:CD:E9:C7:55:1F:08:2B:5D:5D:C6
mysslcert, Jan 16, 2019, PrivateKeyEntry,
Certificate fingerprint (SHA1): 2A:B4:24:7D:2F:E1:E4:E3:E0:7C:90:00:87:88:91:DD:15:39:EC:D8

Then I added a second connector for testing:

<Connector port="59443" protocol="org.apache.coyote.http11.Http11NioProtocol"
    maxThreads="150" SSLEnabled="true" scheme="https" compression="2048" clientAuth="true"
    secure="true" SSLVerifyClient="require" SSLEngine="on"
    sslProtocol="TLSv1.2" URIEncoding="UTF-8" sslEnabledProtocols="TLSv1.2"
    keystoreFile="conf/keystore" keystorePass="changeit"
    truststoreFile="conf/keystore" truststorePass="changeit"
    ciphers="TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
    maxSwallowSize="0"/>

When I try to connect, I get a popup:

Please enter the master password for the Oberthur ID One v7PIV PIV pro...

I don't know that password. Trying my PIN doesn't work. Any ideas? I'm wondering if I need to do more to tell Tomcat about my root CA.

Burrussburry answered 18/2, 2019 at 19:56 Comment(0)
B
1

I mostly got it working my splitting key store into two parts. The actual key store now contains just the SSL certificate, the other is named 'piv-truststore' and contains only the smart card certificates. This seems to be working. I get the same prompt to "enter the master password" but now it accepts my PIN (if and only if my smart card is inserted into a reader).

<Connector port="59443" protocol="org.apache.coyote.http11.Http11NioProtocol"
    maxThreads="150" SSLEnabled="true" scheme="https" compression="2048" clientAuth="true"
    secure="true" SSLVerifyClient="require" SSLEngine="on" 
    sslProtocol="TLSv1.2" URIEncoding="UTF-8" sslEnabledProtocols="TLSv1.2"
    keystoreFile="conf/keystore" keystorePass="changeit"
    truststoreFile="conf/piv-truststore" truststorePass="changeit"
    ciphers="TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
    maxSwallowSize="0"/>

There's still one issue, which is that I still get prompted to log in using a password. I suspect I need to set up a special realm or something that will complete AD authentication.

[Update] Three months later, I have made much progress. I found a Java class that lets me use a smartcard and fall back to a form. https://github.com/samwyse/SSLWithFORMFallback8

Burrussburry answered 5/3, 2019 at 18:41 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.