Chapter 10. Troubleshooting authentication with smart cards
You can diagnose smart card failures by systematically validating hardware recognition, service status, and certificate validity to resolve common configuration issues to restore secure access.
10.1. Testing smart card access on the system Copy linkLink copied to clipboard!
Verifying hardware connectivity is the first step in troubleshooting. Use system utilities such as lsusb and pkcs11-tool to confirm the reader is active and that the operating system can read the smart card’s contents.
Prerequisites
- You have installed and configured your IdM Server and client for use with smart cards.
-
You have installed the
certutiltool from thenss-toolspackage. - You have the PIN or password for your smart card.
Procedure
Using the
lsusbcommand, verify that the smart card reader is visible to the operating system:lsusb
$ lsusbCopy to Clipboard Copied! Toggle word wrap Toggle overflow Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 003: ID 072f:b100 Advanced Card Systems, Ltd ACR39U Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 003: ID 072f:b100 Advanced Card Systems, Ltd ACR39U Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubCopy to Clipboard Copied! Toggle word wrap Toggle overflow For more information about the smart cards and readers tested and supported in RHEL, see Smart Card support in RHEL 10.
Ensure that the
pcscdservice and socket are enabled and running:systemctl status pcscd.service pcscd.socket
$ systemctl status pcscd.service pcscd.socketCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Using the
p11-kit list-modulescommand, display information about the configured smart card and the tokens present on the smart card:p11-kit list-modules
$ p11-kit list-modulesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify you can access the contents of your smart card:
pkcs11-tool --list-objects --login
$ pkcs11-tool --list-objects --loginCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display the contents of the certificate on your smart card using the
certutilcommand:Run the following command to determine the correct name of your certificate:
certutil -d /etc/pki/nssdb -L -h all
$ certutil -d /etc/pki/nssdb -L -h allCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display the contents of the certificate on your smart card:
NoteEnsure the name of the certificate is an exact match for the output displayed in the previous step, in this example
MyEID (sctest):Certificate.certutil -d /etc/pki/nssdb -L -n "MyEID (sctest):Certificate"
$ certutil -d /etc/pki/nssdb -L -n "MyEID (sctest):Certificate"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow
10.2. Troubleshooting smart card authentication with SSSD Copy linkLink copied to clipboard!
SSSD manages the authentication flow between the smart card and the identity provider. Administrators analyze SSSD logs and use sssctl to diagnose failures in the pam or krb5 child processes when login attempts fail.
Prerequisites
- You have installed and configured your IdM Server and client for use with smart cards.
-
You have installed the
sssd-toolspackage. - You are able to detect your smart card reader and display the contents of your smart card. See Testing smart card access on the system.
Procedure
Verify you can authenticate with your smart card using
su:su - idmuser1 -c ‘su - idmuser1 -c whoami'
$ su - idmuser1 -c ‘su - idmuser1 -c whoami'Copy to Clipboard Copied! Toggle word wrap Toggle overflow PIN for MyEID (sctest): idmuser1
PIN for MyEID (sctest): idmuser1Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you are not prompted for the smart card PIN, and either a password prompt or an authorization error are returned, check the SSSD logs. See Troubleshooting authentication with SSSD in IdM for information about logging in SSSD. The following is an example of an authentication failure:
su - idmuser1 -c ‘su - idmuser1 -c whoami'
$ su - idmuser1 -c ‘su - idmuser1 -c whoami'Copy to Clipboard Copied! Toggle word wrap Toggle overflow PIN for MyEID (sctest): su: Authentication failure
PIN for MyEID (sctest): su: Authentication failureCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the SSSD logs indicate an issue from the
krb5_child, similar to the following, you may have an issue with your CA certificates. To troubleshoot issues with certificates, see Verifying that IdM Kerberos KDC can use Pkinit and that the CA certificates are correctly located.[Pre-authentication failed: Failed to verify own certificate (depth 0): unable to get local issuer certificate: could not load the shared library]
[Pre-authentication failed: Failed to verify own certificate (depth 0): unable to get local issuer certificate: could not load the shared library]Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the SSSD logs indicate a timeout either from
p11_childorkrb5_child, you may need to increase the SSSD timeouts and try authenticating again with your smart card. See Increasing SSSD timeouts for details on how to increase the timeouts.Verify your GDM smart card authentication configuration is correct. A success message for PAM authentication should be returned as shown below:
sssctl user-checks -s gdm-smartcard "idmuser1" -a auth
# sssctl user-checks -s gdm-smartcard "idmuser1" -a authCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow If an authentication error, similar to the following, is returned, check the SSSD logs to try and determine what is causing the issue. See Troubleshooting authentication with SSSD in IdM for information about logging in SSSD.
pam_authenticate for user [idmuser1]: Authentication failure PAM Environment: - no env -
pam_authenticate for user [idmuser1]: Authentication failure PAM Environment: - no env -Copy to Clipboard Copied! Toggle word wrap Toggle overflow If PAM authentication continues to fail, clear your cache and run the command again.
sssctl cache-remove
# sssctl cache-removeCopy to Clipboard Copied! Toggle word wrap Toggle overflow SSSD must not be running. Stop SSSD now? (yes/no) [yes] yes Creating backup of local data… Removing cache files… SSSD needs to be running. Start SSSD now? (yes/no) [yes] yes
SSSD must not be running. Stop SSSD now? (yes/no) [yes] yes Creating backup of local data… Removing cache files… SSSD needs to be running. Start SSSD now? (yes/no) [yes] yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow
10.3. Verifying that IdM Kerberos KDC can use PKINIT and that the CA certificates are correctly located Copy linkLink copied to clipboard!
Successful PKINIT authentication relies on a valid certificate chain. You can use kinit and openssl to verify that the client trusts the Certificate Authority and that the smart card certificate is valid for Kerberos ticket retrieval.
Prerequisites
- You have installed and configured your IdM Server and client for use with smart cards.
- You are able to detect your smart card reader and display the contents of your smart card. See Testing smart card access on the system.
Procedure
Run the
kinitutility to authenticate as theidmuser1with the certificate stored on your smart card:kinit -X X509_user_identity=PKCS11: idmuser1
$ kinit -X X509_user_identity=PKCS11: idmuser1Copy to Clipboard Copied! Toggle word wrap Toggle overflow MyEID (sctest) PIN:
MyEID (sctest) PIN:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Enter your smart card PIN. If you are not prompted for your PIN, check that you can detect your smart card reader and display the contents of your smart card. See link:https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/managing_smart_card_authentication/troubleshooting-authentication-with-smart-cards#testing-smart-card-access-on-the-system
If your PIN is accepted and you are then prompted for your password, you might be missing your CA signing certificate.
Verify the CA chain is listed in the default certificate bundle file using
opensslcommands:openssl crl2pkcs7 -nocrl -certfile /var/lib/ipa-client/pki/ca-bundle.pem | openssl pkcs7 -print_certs -noout
$ openssl crl2pkcs7 -nocrl -certfile /var/lib/ipa-client/pki/ca-bundle.pem | openssl pkcs7 -print_certs -nooutCopy to Clipboard Copied! Toggle word wrap Toggle overflow subject=O = IDM.EXAMPLE.COM, CN = Certificate Authority issuer=O = IDM.EXAMPLE.COM, CN = Certificate Authority
subject=O = IDM.EXAMPLE.COM, CN = Certificate Authority issuer=O = IDM.EXAMPLE.COM, CN = Certificate AuthorityCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the validity of your certificates:
Find the user authentication certificate ID for
idmuser1:pkcs11-tool --list-objects --login
$ pkcs11-tool --list-objects --loginCopy to Clipboard Copied! Toggle word wrap Toggle overflow [...] Certificate Object; type = X.509 cert label: Certificate subject: DN: O=IDM.EXAMPLE.COM, CN=idmuser1 ID: 01
[...] Certificate Object; type = X.509 cert label: Certificate subject: DN: O=IDM.EXAMPLE.COM, CN=idmuser1 ID: 01Copy to Clipboard Copied! Toggle word wrap Toggle overflow Read the user certificate information from the smart card in DER format:
pkcs11-tool --read-object --id 01 --type cert --output-file cert.der
$ pkcs11-tool --read-object --id 01 --type cert --output-file cert.derCopy to Clipboard Copied! Toggle word wrap Toggle overflow Using slot 0 with a present token (0x0)
Using slot 0 with a present token (0x0)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Convert the DER certificate to PEM format:
openssl x509 -in cert.der -inform DER -out cert.pem -outform PEM
$ openssl x509 -in cert.der -inform DER -out cert.pem -outform PEMCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the certificate has valid issuer signatures up to the CA:
openssl verify -CAfile /var/lib/ipa-client/pki/ca-bundle.pem <path>/cert.pem cert.pem: OK
$ openssl verify -CAfile /var/lib/ipa-client/pki/ca-bundle.pem <path>/cert.pem cert.pem: OKCopy to Clipboard Copied! Toggle word wrap Toggle overflow
If your smart card contains several certificates,
kinitmight fail to choose the correct certificate for authentication. In this case, you need to specify the certificate ID as an argument to thekinitcommand using thecertid=<ID>option.Check how many certificates are stored on the smart card and get the certificate ID for the one you are using:
pkcs11-tool --list-objects --type cert --login
$ pkcs11-tool --list-objects --type cert --loginCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run
kinitwith certificate ID 01:kinit -X kinit -X X509_user_identity=PKCS11:certid=01 idmuser1
$ kinit -X kinit -X X509_user_identity=PKCS11:certid=01 idmuser1Copy to Clipboard Copied! Toggle word wrap Toggle overflow MyEID (sctest) PIN:
MyEID (sctest) PIN:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Run
klistto view the contents of the Kerberos credentials cache:klist
$ klistCopy to Clipboard Copied! Toggle word wrap Toggle overflow Ticket cache: KCM:0:11485 Default principal: idmuser1@EXAMPLE.COM Valid starting Expires Service principal 10/04/2021 10:50:04 10/05/2021 10:49:55 krbtgt/EXAMPLE.COM@EXAMPLE.COM
Ticket cache: KCM:0:11485 Default principal: idmuser1@EXAMPLE.COM Valid starting Expires Service principal 10/04/2021 10:50:04 10/05/2021 10:49:55 krbtgt/EXAMPLE.COM@EXAMPLE.COMCopy to Clipboard Copied! Toggle word wrap Toggle overflow Destroy your active Kerberos tickets once you have finished:
kdestroy -A
$ kdestroy -ACopy to Clipboard Copied! Toggle word wrap Toggle overflow
10.4. Increasing SSSD timeouts Copy linkLink copied to clipboard!
Hardware latency or complex certificate chains can cause SSSD operations to time out. Administrators extend the krb5_auth_timeout and p11_child_timeout settings in sssd.conf to enable sufficient time for smart card processing.
krb5_child: Timeout for child [9607] reached.....consider increasing value of krb5_auth_timeout.
krb5_child: Timeout for child [9607] reached.....consider increasing value of krb5_auth_timeout.
If there is a timeout entry in the log file, try increasing the SSSD timeouts as outlined in this procedure.
Prerequisites
- You have configured your IdM Server and client for smart card authentication.
Procedure
Open the
sssd.conffile on the IdM client:vim /etc/sssd/sssd.conf
# vim /etc/sssd/sssd.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow In your domain section, for example
[domain/idm.example.com], add the following option:krb5_auth_timeout = 60
krb5_auth_timeout = 60Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the
[pam]section, add the following:p11_child_timeout = 60
p11_child_timeout = 60Copy to Clipboard Copied! Toggle word wrap Toggle overflow Clear the SSSD cache:
sssctl cache-remove
# sssctl cache-removeCopy to Clipboard Copied! Toggle word wrap Toggle overflow SSSD must not be running. Stop SSSD now? (yes/no) [yes] yes Creating backup of local data… Removing cache files… SSSD needs to be running. Start SSSD now? (yes/no) [yes] yes
SSSD must not be running. Stop SSSD now? (yes/no) [yes] yes Creating backup of local data… Removing cache files… SSSD needs to be running. Start SSSD now? (yes/no) [yes] yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Once you have increased the timeouts, try authenticating again using your smart card. See Testing smart card authentication for more details.