Setting up Windows Server for YubiKey PIV authentication


Configuring a certification authority (CA) for smart card authentication

In order to utilize the smart card functions in a Windows environment using the YubiKey Smart Card Minidriver, a certification authority (CA) must first be stood up.

This section covers the basic configuration for setting up a new certification authority (CA) to a Windows Server (2016 and above). These steps assume an Active Directory environment is already in place and configured.

bulb-light-icon.svg Tip: If a certification authority already exists and is configured in your environment, skip to Adding support for elliptic curve cryptography (ECC) certificate login.

Certification authority prerequisites

exclamation-triangle-line-icon.svg Warning: The installation should be performed by an experienced system administrator. These instructions include steps for a basic configuration. For information about implementing advanced configurations, see this Microsoft article.

Before you create a certification authority (CA), be sure you set up a Microsoft Windows Active Directory domain environment. 

Microsoft recommends that you do not deploy a root certification authority (CA) on a domain controller. As an additional security measure, consider installing the root CA on a standalone offline server, and use a subordinate CA for all certificate signing. For more information, see this Microsoft article.

Creating a certification authority

Follow the steps below to create a certification authority.

  1. Open Server Manager and choose Add roles and features, and click Next.

  2. Select Role-based or feature-based installation, and click Next.

  3. Click Select a server from the server pool, and from Server Pool, select the server on which you want to install the Certification Authority. Click Next.

  4. Under Server Roles, select Active Directory Certificate Services, and click Next.

  5. Click Add Features, and click Next, and then Next again.

  6. Select Certification Authority, and click Next.

  7. Click Install. Allow several minutes for the process to complete.

  8. Select Configure Active Directory Certificate Services on the destination server, and click Next.

  9. Select Certification Authority, and click Next.

  10. Choose Enterprise CA, and click Next.

  11. Choose Root CA, and click Next.

  12. Select Create a new private key, and click Next.

  13. Select the cryptographic provider, hash algorithm, and key length for the private key, and click Next.

    exclamation-triangle-line-icon.svg Warning: If you choose to change the cryptographic provider, hash algorithm, or key length from the default values, making such changes may increase the size of smart card login certificates beyond the available space on the YubiKey. Be sure the values you select are supported by the YubiKeys that you will use in your environment, as shown below.
  Maximum
supported
certificate size
Supported key lengths (bits) Supported hash algorithms Encryption
YubiKey 4/5 3052 bytes RSA: 1024, 2048
ECDSA: P256, P384
SHA256, SHA384 RSA, ECDH
  1. Common name and Distinguished name will be automatically populated. Confirm the values match the server name and domain name, and click Next.

  2. Select the validity period for the Certification Authority certificate, and click Next.

    bulb-light-icon.svg Tip: This period must be longer than what you set for the smart card login certificate template. Yubico recommends the default value of 5 years.
  3. Leave the Database locations to the default values and click Next again.

  4. Verify all settings match the desired values, and click Configure.

  5. When the process completes, exit the installation wizard by clicking Close.

 

Adding support for elliptic curve cryptography (ECC) certificate login

By default, ECC certificates are not supported for domain login in Active Directory. In order to allow ECC certificates for domain login, a GPO must be set. This can be done either through Group Policy or by editing the registry on the local system (in the case of a system where Group Policy is not managed by the domain). These topics are described below.

Adding ECC through a Group Policy Object

  1. Right-click the Start button and select Run.

  2. Type gpmc.msc and press Enter.

  3. Navigate to the AD forest and domain containing your server, double-click your server and double-click Group Policy Objects.

  4. Right-click on the Group Policy you want to edit, and then select Edit.

  5. Expand Computer Configuration > Policies > Administrative Templates > Windows Components > Smart Card.

  6. Right-click on Allow ECC certificates to be used for logon and authentication and select Edit.

  7. On the Edit window select Enabled.

  8. Click OK.

  9. Allow Active Directory to update. Depending on your environment, it could take up to eight hours for the template to publish to Active Directory.

Adding ECC through the local registry

In the event a machine cannot be managed via Group Policy, support for ECC certificates can be done through the local registry.

  1. Right-click the Start button and select Run.

  2. Type regedit and press Enter.

  3. Expand HKEY_LOCAL_MACHINE > SOFTWARE > Policies > Microsoft > Windows > SmartCardCredentialProvider

    bulb-light-icon.svg Tip: It is possible that SmartCardCredentialProvider doesn’t currently    exist. If that is the case, right-click the Start Menu button, select New > Key and then name it SmartCardCredentialProvider.
  4. With SmartCardCredentialProvider highlighted, open the Edit menu and select New > DWORD (32-bit) Value.

  5. Name the new object EnumerateECCCerts.

  6. Right-click on EnumerateECCCerts and select Modify…

  7. Set the Value data to 1 and click OK.

  8. Close Registry Editor.

Changing the behavior for your domain when you remove the smart card

When a user logs into the domain account using a smart card, by default, the user can remove the smart card at any point with no change to the login status. For security reasons, you may want to enforce a different behavior. In Group Policy, you can specify that Windows locks the user account, or logs out the user if the smart card is removed at any point while the user is logged in to the account. 

Editing Group Policy to lock the user's workstation when a smart card is removed

  1. Right-click the Start button and select Run.

  2. Type gpmc.msc and press Enter.

  3. Right-click on the group policy you want to edit, and then select Edit.

  4. Expand Computer Configuration > Policies > Windows Settings > Security Settings > Local Policies > Security Options.

  5. On the left pane, locate and right-click Interactive Logon: Smart card removal behavior, and select Properties

  6. Click Local Security Setting, and set it to Lock Workstation or Force Logoff, depending on your requirements.

  7. Click Apply, and then click OK.

Working with enterprise root certificates

In order to log on to a Windows system with a smart card, the system needs to be able to build the entire certificate chain from the smart card to the root CA. For a standard forest running Active Directory Certificate Services, Windows can manage the trust chain for the YubiKey smart card authentication automatically. Storing the certificate chain on the smart card may be a desirable alternative to deploying all of the intermediate certificates to every system. Storing the certificate chain on the YubiKey does not remove the need to ensure that the system trusts the root CA, so this feature only helps the client system build the certificate chain to an already trusted root. Common situations covered are: including systems on a multi-forest domain, users logging onto domain accounts from non-domain systems, and deployments adding new systems to a domain using a smart card for authentication.

Adding a root certificate does require the YubiKey Smart Card Minidriver to be installed on the server and client systems. See Deploying the YubiKey Smart Card Minidriver to workstations and servers for more information.

bulb-light-icon.svg Tip: In order to run the 'certutil -scroots update' command successfully, the management key must be set to it's default value. If the management key has been changed, the YubiKey will become read-only and adding additional certificates via certutil will not be possible.

Adding an enterprise root certificate to the YubiKey

  1. Right-click the Start button and select Windows PowerShell (Admin) or Command Prompt (Administrator), depending on your Windows build.

  2. Type in the following command and press Enter:
    certutil -scroots update

  3. When prompted for your Windows Security PIN, enter the PIN for your smart card and then press Enter.

  4. To verify both the smart card certificate and the root certificate are loaded to the smart card, type in the following command and then press Enter:
    certutil -scinfo

    You are prompted to enter your smart card PIN several times. Enter it each time it is requested.

  5. To verify a root certificate is enrolled, type in the following command and then press Enter:
    certutil -scroots view

Manually deleting certificates

To delete certificates from a certificate chain manually, including a Base CSP container and associated key/certificate on the YubiKey 4/5 through the YubiKey Smart Card Minidriver, use the certutil command line program. To list the current containers on the card, use the following command: 

certutil -key -csp "Microsoft Base Smart Card Crypto Provider"

This returns a list of container names and key types.  To remove a container cleanly, use the following command while running with elevated permissions as administrator:

certutil -delkey -csp "Microsoft Base Smart Card Crypto Provider" "<container name>"

Next steps

This section helps you determine the next steps in your YubiKey smart card deployment process using the YubiKey Smart Card Minidriver.  

Setting up smart card login for user self-enrollment

If auto-enrollment has been set up in your environment, your users should be prompted to register a smart card the next time they log into their accounts.

Setting up smart card login for enroll on behalf of

The YubiKey Smart Card Minidriver allows for an admin or user with elevated permissions to enroll on behalf of other users. This is useful for deployments where the YubiKeys need to be provisioned from a central location, or replacement YubiKeys need to be generated for users who have blocked their PIN and are unable to unblock it.

Windows 11
With Windows 11, the Enrollment on Behalf of Other Users dialog has been enhanced to allow multiple users to have a YubiKey enrolled using the same template at once. The dialog remains the same, but at the end of the enrollment process, an option to enroll another user can be accessed with the Next User button.

image1.png

Protecting a Microsoft cloud environment with a YubiKey

Microsoft has built an impressive collection of integrated cloud service capabilities that span infrastructure, platforms and applications. Many of these services can also be secured with your YubiKey through Active Directory Federation Services (AD FS). While the steps to do so are outside the scope of this document, interested parties can learn by reading this article.

 

Next: Setting up smart card login for user self-enrollment