Chapter 23. Smart-card Authentication in Identity Management
23.1. Managing Smart Card Links in the Identity Management Server
- If you need to extract the certificate from the smart card, see Section 23.1.1, “Exporting a Certificate From a Smart Card”.
23.1.1. Exporting a Certificate From a Smart Card
- Place the smart card into the reader.
- Use the following command to list the certificates on the smart card. In the output, locate the certificate to use for authentication, and note its nickname:
$
certutil -L -d /etc/pki/nssdb/ -h allCertificate Nickname Trust Attributes SSL,S/MIME,JAR/XPI my_certificate CT,C,C - Extract the certificate to a file using the certificate nickname. For example, to extract the certificate in the Base64 format to a file named
user.crt:$
certutil -L -d /etc/pki/nssdb/ -n 'my_certificate' -r | base64 -w 0 > user.crtThebase64utility is part of the coreutils package.
23.1.2. Linking User Accounts to Smart Card Certificates
- Using the full certificate blob:
- For Identity Management users, see Section 23.1.2.1, “Creating a Link Between a Certificate and a User Account”. You can also remove such link using Section 23.1.2.2, “Removing a Link Between a Certificate and a User Account”.
- For Active Directory users, see Section 23.1.2.3, “Linking an Active Directory User Account and a Smart Card”.
- Using certificate mapping: Section 23.1.2.4, “Configuring Identity Mapping”
23.1.2.1. Creating a Link Between a Certificate and a User Account
Command Line: Creating a Link Between a Certificate and a User Account
- Log in as the Identity Management administrator:
$
kinit admin - Add the smart card certificate to the user account using the
ipa user-add-certcommand. For example:$
cat cert.pem | tail -n +2 | head -n -1 | tr -d '\r\n' | ipa user-add-cert idm_user
Web UI: Creating a Link Between a Certificate and a User Account
- Select → , and click on the required user account.
- Click next to the Certificates entry, and enter the certificate.
- Click at the top of the user account page.
Additional Resources
- For details on adding and removing certificates issued by an external certificate authority (CA), see Section 24.2, “Managing Certificates Issued by External CAs”.
23.1.2.2. Removing a Link Between a Certificate and a User Account
Command Line: Creating a Link Between a Certificate and a User Account
- Log in as the Identity Management administrator:
$
kinit admin - Find the required user account:
$
ipa user-show idm_userUser login: idm_user First name: first_name Last name: last_name ... Certificate: MIIC3... - Remove the certificate from the account:
$
ipa user-remove-cert idm_user --certificate MIIC3...
Web UI: Removing a Link Between a Certificate and a User Account
- Select → , and click on the required user account.
- Click next to the certificate to delete, and select .
Additional Resources
23.1.2.3. Linking an Active Directory User Account and a Smart Card
Command Line: Linking an Active Directory User Account and a Smart Card
- Log in as the Identity Management administrator:
$
kinit admin - Create an environment variable (
CERT) for the user certificate:$
CERT=`cat cert.pem | tail -n +2 | head -n -1 | tr -d '\r\n'` - Add the user certificate to the ID view by creating a new ID override. In this procedure, we are using the Default Trust View:
$
ipa idoverrideuser-add 'Default Trust View' ad_user@ad.example.com --certificate $CERT
Web UI: Linking an Active Directory User Account and a Smart Card
- Select → , and click on the required ID view.
- Add the user certificate to the ID view by creating a new ID override. Click , and fill out the required information in the Add User ID override form.
Additional Resources
- For details on managing ID views, see Chapter 18, ID Views.
- For details on the Default Trust View, see Using ID Views in Active Directory Environments.
23.1.2.4. Configuring Identity Mapping
23.1.2.4.1. Identity Mapping in Identity Management
- Mapping rule
- A mapping rule associates (or maps) a certificate with one or more user accounts. The rule defines an LDAP search filter that associates a certificate with the intended user account.Certificates issued by different certificate authorities (CAs) might have different properties and might be used in different domains. Therefore, Identity Management does not apply mapping rules unconditionally, but only to the appropriate certificates. The appropriate certificates are defined using matching rules.
- Matching rule
- A matching rule selects a certificate or CA to which you want to apply the mapping rule.
- Domain list
- The domain list specifies the DNS domain names in which you want Identity Management to search the users when processing identity mapping rules.
Note
If you do not specify any domains, Identity Management searches the users only in the local domain to which the client belongs. - Priority
- When multiple rules are applicable to a certificate, the rule with the highest priority takes precedence. All other rules are ignored.
- The lower the numerical value, the higher the priority of the identity mapping rule. For example, a rule with a priority 1 has higher priority than a rule with a priority 2.
- If a rule has no priority value defined, it has the lowest priority.
23.1.2.4.2. Creating a Certificate Identity Mapping Rule
Command Line: Creating a Certificate Identity Mapping Rule
- Log in as the administrator:
$
kinit admin - Create the rule by using the
ipa certmaprule-addcommand. To specify the components for the identity mapping rule, use these options:--mapruledefines the mapping rule--matchruledefines the matching rule--domaindefines the domain in which you want to search the user entry--prioritydefines the priority of the identity mapping rule
For example, to create a simple identity mapping rule that consists only of a mapping rule and a matching rule:$
ipa certmaprule-add rule_name --matchrule '<ISSUER>CN=Smart Card CA,O=EXAMPLE.ORG' --maprule '(ipacertmapdata=X509:<I>{issuer_dn!nss_x500}<S>{subject_dn!nss_x500})'------------------------------------------------------- Added Certificate Identity Mapping Rule "rule_name" ------------------------------------------------------- Rule name: rule_name Mapping rule: (ipacertmapdata=X509:<I>{issuer_dn!nss_x500}<S>{subject_dn!nss_x500}) Matching rule: <ISSUER>CN=Smart Card CA,O=EXAMPLE.ORG Enabled: TRUEThis rule now links the subject and issuer from the smart card certificate to the value of theipacertmapdataattribute in the user account.
Web UI: Creating a Certificate Identity Mapping Rule
- Select → .
- Click .
- Fill out the components of the rule, and click .
Additional Resources
- For details on the syntax of the certificate mapping and matching rules, see the sss-certmap(5) man page.
- For details on using the
ipa certmaprule-addcommand, execute it with the--helpoption. - For additional commands for managing identity mapping, use the
ipa help certmapcommand.
23.1.2.4.3. Linking a User Account and a Smart Card Certificate
ipacertmapdata attribute.
Command Line: Linking a User Account and a Smart Card Certificate
- If you have access to the certificate, use the full certificate blob:
$
CERT=`cat cert.pem | tail -n +2| head -n -1 | tr -d '\r\n'`$ipa user-add-certmapdata idm_user --certificate $CERT-------------------------------------------- Added certificate mappings to user "idm_user" -------------------------------------------- User login: idm_user Certificate mapping data: X509:<I>O=EXAMPLE.ORG,CN=Smart Card CA<S>CN=test,O=EXAMPLE.ORG - If you do not have access to the certificate, but know the subject and issuer, use the
--subjectand--issueroptions:$
ipa user-add-certmapdata idm_user --subject "O=EXAMPLE.ORG,CN=test" --issuer "CN=Smart Card CA,O=EXAMPLE.ORG"-------------------------------------------- Added certificate mappings to user "idm_user" -------------------------------------------- User login: idm_user Certificate mapping data: X509:<I>O=EXAMPLE.ORG,CN=Smart Card CA<S>CN=test,O=EXAMPLE.ORG - If you are comfortable with the mapping format, provide the mapping data directly:
$
ipa user-add-certmapdata idm_user 'X509:<I>O=EXAMPLE.ORG,CN=Smart Card CA<S>CN=test,O=EXAMPLE.ORG'-------------------------------------------- Added certificate mappings to user "idm_user" -------------------------------------------- User login: idm_user Certificate mapping data: X509:<I>O=EXAMPLE.ORG,CN=Smart Card CA<S>CN=test,O=EXAMPLE.ORG
Web UI: Linking a User Account and a Smart Card Certificate
- Click → , and click on the required user login.
- Click next to the Certificate mapping data entry.

Figure 23.1. Adding certificate mapping data
- In the Add Certificate Mapping Data form, fill out the required information. Specify one of the following:
- The full certificate blob under Certificate
- The subject and issuer under Issuer and subject
- The mapping data directly under Certificate mapping data
Additional Resources
- For details on the
ipa user-add-certmapdatacommand, execute it with the--helpoption.
23.1.2.4.4. Examples of Identity Mapping Rules
Example 23.1. Active Directory Certificates for Identity Management Users
$ipa certmaprule-add ad_cert_for_ipa_users \--maprule='(ipacertmapdata=X509:<I>{issuer_dn!nss_x500}<S>{subject_dn!nss_x500})' \--matchrule='<ISSUER>CN=AD-ROOT-CA,DC=ad,DC=example,DC=com' \--domain=idm.example.com
Example 23.2. Active Directory Certificates for Active Directory Users
$ipa certmaprule-add ad_cert_for_ad_users \--maprule='(altSecurityIdentities=X509:<I>{issuer_dn!ad_x500}<S>{subject_dn!ad_x500})' \--matchrule='<ISSUER>CN=AD-ROOT-CA,DC=ad,DC=example,DC=com' \--domain=ad.example.com
Example 23.3. Active Directory Certificates for Both Identity Management and Active Directory Users
$ipa certmaprule-add ad_cert_for_ipa_and_ad_users \--maprule='(|(ipacertmapdata=X509:<I>{issuer_dn!nss_x500}<S>{subject_dn!nss_x500})(altSecurityIdentities=X509:<I>{issuer_dn!ad_x500}<S>{subject_dn!ad_x500}))' \--matchrule='<ISSUER>CN=AD-ROOT-CA,DC=ad,DC=example,DC=com' \--domain=ad.example.com
--maprule option includes these criteria:
ipacertmapdata=X509:<I>{issuer_dn!nss_x500}<S>{subject_dn!nss_x500}is a filter that links the subject and issuer from a smart card certificate to the value of theipacertmapdataattribute in an Identity Management user accountaltSecurityIdentities=X509:<I>{issuer_dn!ad_x500}<S>{subject_dn!ad_x500}is a filter that links the subject and issuer from a smart card certificate to the value of thealtSecurityIdentitiesattribute in an Active Directory user account
--maprule option accepts the logical operator | (or), so that you can specify multiple criteria. In this case, the rule maps all user accounts that meet at least one of the criteria.
Example 23.4. Identity Management Certificates for Identity Management and Active Directory Users
$ipa certmaprule-add ipa_cert_for_ad_users \--maprule='(|(userCertificate;binary={cert!bin})(ipacertmapdata=X509:<I>{issuer_dn!nss_x500}<S>{subject_dn!nss_x500})(altSecurityIdentities=X509:<I>{issuer_dn!ad_x500}<S>{subject_dn!ad_x500}))' \--matchrule='<ISSUER>CN=Certificate Authority,O=REALM.EXAMPLE.COM' \--domain=idm.example.com --domain=ad.example.com
--maprule option includes these criteria:
userCertificate;binary={cert!bin}is a filter that returns Identity Management or Active Directory user entries that include the whole certificateipacertmapdata=X509:<I>{issuer_dn!nss_x500}<S>{subject_dn!nss_x500}is a filter that links the subject and issuer from a smart card certificate to the value of theipacertmapdataattribute in an Identity Management user accountaltSecurityIdentities=X509:<I>{issuer_dn!ad_x500}<S>{subject_dn!ad_x500}is a filter that links the subject and issuer from a smart card certificate to the value of thealtSecurityIdentitiesattribute in an Active Directory user account
--maprule option accepts the logical operator | (or), so that you can specify multiple criteria. In this case, the rule maps all user accounts that meet at least one of the criteria.
23.1.2.4.5. Examples of Translating the Issuer from a Certificate to a Matching Rule
Example 23.5. Translating the Issuer from a Certificate Issued by Identity Management
# openssl x509 -in user.crt -noout -issuer
issuer= /O=REALM.EXAMPLE.COM/CN=Certificate Authority'<ISSUER>CN=Certificate Authority,O=REALM.EXAMPLE.COM'
Example 23.6. Translating the Issuer from a Certificate with an Email Included
# openssl x509 -in expired_user.pem -noout -issuer
issuer= /C=US/ST=North Carolina/L=Raleigh/O=Red Hat/OU=QE/CN=ExampleCA/emailAddress=admin@example.com'<ISSUER>emailAddress=admin@example.com,CN=ExampleCA,OU=QE,O=Red Hat,L=Raleigh,ST=North Carolina,C=US'
23.1.2.5. Additional Resources
- To verify the smart-card certificate links, see Section 23.1.3, “Finding Users That Match a Specified Certificate”.
- For more details on identity mapping for certificates, see Matching and Mapping Certificates in the upstream SSSD documentation.
23.1.3. Finding Users That Match a Specified Certificate
Command Line: Finding Users That Match a Specified Certificate
- Log in as the administrator:
$
kinit admin - To find the user, specify one of the following:
- The name of the certificate file:
$
ipa certmap-match cert.pem-------------- 1 user matched -------------- Domain: IDM.EXAMPLE.COM User logins: idm_user ---------------------------- Number of entries returned 1 ---------------------------- - The contents of the certificate:
$
ipa certmap-match --certificate="MII...."-------------- 1 user matched -------------- Domain: IDM.EXAMPLE.COM User logins: idm_user ---------------------------- Number of entries returned 1 ----------------------------This command returns also users in a trusted Active Directory domain if their user entries contain the full certificate blob:$
ipa certmap-match --certificate="MII...."--------------- 2 users matched --------------- Domain: ad.domain.com User logins: ad_user Domain: IDM.EXAMPLE.COM User logins: idm_user ---------------------------- Number of entries returned 2 ----------------------------
Web UI: Finding Users That Match a Specified Certificate
- Click → → .
- Enter the contents of the certificate in the Certificate field, and click . Identity Management displays the users who match the certificate under Matched Users.

Figure 23.2. List of users who match a certificate
Additional Resources
- For details on the commands for certificate identity mapping, use the
ipa help certmapcommand. - For details on the
ipa certmap-matchcommand, execute it with the--helpoption.
23.1.4. Additional Resources
- For information on managing personal certificates and keys using the Enterprise Security Client, an application for Red Hat Certificate System, see Managing Smart Cards with the Enterprise Security Client in the Certificate System documentation.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.