When a smart card is inserted, the following steps are performed:
Note |
|---|
|
Unless otherwise mentioned, all operations are performed silently (CRYPT_SILENT is passed to CryptAcquireContext). |
-
The smart card resource manager database queries for the smart card's CSP.
-
A qualified container name is constructed using the reader name obtained and is passed to the CSP. The format for that name is as follows: \\.\<Reader name>\
- CryptAcquireContext is called to retrieve a context to the default container. A failure here would cause the smart card to be unusable for smart card logon.
-
The name of the container is retrieved by requesting the PP_CONTAINER parameter using CryptGetProvParam.
-
Using the context acquired in Step 3, the CSP is queried for the PP_USER_CERTSTORE parameter, which was added in Windows Vista. (See Smart card subsystem architecture for more information.) If the operation is successful, a certificate store is returned, and the program flow skips to Step 8.
-
If the operation in Step 5 fails, then the default container context from Step 3 is queried for the AT_KEYEXCHANGE key.
-
The certificate is then queried from the key context using KP_CERTIFICATE. The certificate is added to an in-memory certificate store.
-
For each certificate in the certificate store from either Step 5 or Step 7, the following checks are performed:
-
The certificate must be valid based on the computer system clock (not expired or valid in the future).
-
The certificate must not be in the AT_SIGNATURE part of a container.
-
The certificate must have a valid UPN.
-
The certificate must have the Digital Signature Key Usage.
-
The certificate must have the smart card logon EKU.
These requirements are the same requirements as in Windows 2003, but they are performed before the user enters the PIN. You can override many of them by using Group Policy settings.
Any certificate that meets these requirements is displayed to the user along with the certificate's UPN (or e-mail address or subject, depending on the presence of the certificate extensions).
-
A certificate is then chosen, and the PIN is entered.
-
LogonUI.exe packages the information and sends it to lsass.exe to process the logon attempt.
-
If successful, logonUI.exe is torn down. This causes the context acquired in Step 3 to be released.
Smart card logon flow in Windows Vista
Most problems during authentication will occur because of session behavior. Also, the LSA does not reacquire the context; it relies instead on the CSP to handle the session change.
enables support of client certificates that do not contain a UPN in the subjectAltName (SAN) field of the certificate and supports a much wider variety of certificates, including multiple certificates.
However, these changes are not enabled by default, except for multiple certificates support. (Some certificates are excluded.) Administrators need to set the registry keys on clients (for example, with Group Policy) to enable the functionality.
clients by default would filter the client's certificates in the smart card by using the client authentication EKU. The credential provider also has a policy, AllowSignatureOnlyKeys (corresponding to the AT_SIGNATURE key value in CAPI), to determine if it needs to filter the client certificates based on a requirement that the logon certificate be able to do encryption by allowing the user to display and select signing-only certificates. These policy settings have a direct bearing on the filtering and resulting display of certificates on the logon UI.
Figure 16 illustrates how smart card logon works in Windows Vista.
Figure 16 Smart card logon flow
Flow sequence:
-
WinLogon requests the logon UI credential information.
-
Asynchronously, smart card resource manager starts. The smart card credential provider:
-
Gets credential information, a list of known credentials or none, or that Windows detected a smart card reader.
-
Gets a list of smart card readers (uses WinSCard API) and the list of smart cards inserted in each of them.
-
Enumerates each card to check if a logon certificate (signing) controlled by Group Policy is present. If the certificate is present, the smart card credential provider copies it into a temporary secure cache on the terminal.
-
Notifies the logon UI that it has new credentials.
-
The logon UI requests the new credentials from the smart card credential provider. As a response, the smart card credential provider provides to the logon UI each logon certificate for which a corresponding logon tile is displayed. The user selects a smart card-based logon certificate tile, and Windows displays a PIN dialog box.
-
The user enters the PIN and clicks Go. The smart card credential provider encrypts the PIN.
-
The credential provider that resides in the LogonUI process (system) collects the PIN. As part of packaging credentials in the smart card credential provider, the data is packaged in a KERB_CERTIFICATE_LOGON structure (defined in CredentialProviders.h). The main contents of the KERB_CERTIFICATE_LOGON structure are smart card PIN, cspdata (contains reader name, container name, etc), User Name and Domain Name. User Name is required if the logon domain is not in the same forest, because it enables a certificate to be mapped to multiple user accounts.
-
The credential provider now wraps the data (such as encrypted PIN, container name, reader name, and card Key Spec) and is sent back to LogonUI.
-
LogonUI presents the data to LSA with Winlogon for LSALogonUser.
-
LSA calls Kerberos Authentication Package (Kerberos SSP) to create a Kerberos Authentication Service Request (KRB_AS_REQ) containing a pre-authenticator (as specified in RFC 4556: Public Key Cryptography for Initial Authentication in Kerberos (PKINIT) (http://go.microsoft.com/fwlink/?LinkId=93352)).
If the authentication is performed using a certificate with a key usage of digital signature, then the pre-authentication data consists of the user’s public certificate, and the certificate is digitally signed with the corresponding private key.
If the authentication is with a certificate with a key usage of key encipherment, then the pre-authentication data consists of the user’s public certificate, and the certificate is encrypted with the corresponding private key.
-
To sign the request digitally (as per RFC 4556), a call is made to the corresponding CSP for a private key operation. Because the private key in this case is stored in a smart card, the smart card sub-system is called, and the necessary operation is completed. The result is sent back to the Kerberos SSP.
-
The Kerberos SSP sends an authentication request (as per RFC 4556) to the Key Distribution Center (KDC) service that runs on a domain controller, to request a Ticket Granting Ticket (TGT).
-
The KDC finds the user’s account object in the active directory, as detailed in Client Certificate Mappings, and uses the user’s certificate to verify the signature.
-
The KDC validates the user’s certificate (time, path, and revocation status) to ensure that the certificate is from a trusted source. The KDC uses CryptoAPI (CAPI2) to build a certification path from the user’s certificate to a Root CA certificate that resides in the root store on the domain controller. The KDC then uses CryptoAPI (CAPI2) to verify the digital signature on the authenticator that was included as signed data in the pre-authentication data fields. The domain controller verifies the signature and uses the public key from the user’s certificate to prove that the request originated from the owner of the private key that corresponds to the public key. The KDC also verifies that the issuer is trusted and appears in the NTAUTH certificate store.
-
The KDC service retrieves user account information from Active Directory. The KDC constructs a TGT based on the user account information that it retrieves from Active Directory. The TGT includes the user's security identifier (SID), the SIDs for universal and global domain groups to which the user belongs, and (in a multi-domain environment) the SIDs for any universal groups of which the user is a member. The TGT’s authorization data fields include the list of SIDs.
-
The domain controller returns the TGT to the client as part of the KRB_AS_REP response.
Note |
|---|
|
The KRB_AS_REP packet consists of:
Privilege attribute certificate (PAC)
User’s security identifier (SID)
SIDs of any groups of which the user is a member
A request for Ticket Granting Service (TGS)
Pre-authentication data |
The response is as per RFC 4556. TGT is encrypted with the master key of the KDC, and the session key is encrypted with a temporary key. This temporary key is derived based on RFC 4556. Using CAPI2 APIs, the temporary key is decrypted. As part of the decryption process, if the private key for the same happens to be on a smart card, then the call is made back to the smart card subsystem using the specified Cryptographic Service Provider to extract the certificate corresponding to the user’s public key. (Programmatic calls include CryptAcquireContext, CryptSetProvParam with the PIN, CryptgetUserKey, CryptGetKeyParam for the certificate.). After the temporary key is obtained, the \ Kerberos SSP decrypts the session key.
-
The client validates the reply from the KDC (time, path and revocation status). It first verifies the KDC’s signature by the construction of a certification path from the KDC’s certificate to a trusted root CA, and then it uses the KDC’s public key to verify the reply signature.
-
Now that a TGT has been obtained, the client obtains a Service Ticket to the local computer in order to log on to the computer.
-
On success, LSA stores the tickets and returns success to the LSALogonUser. On this success message, user profile, Group Policy, and other actions are performed.
-
Once the user profile is loaded, CertPropSvc picks up this event, reads the certificates from the card (including the root certificates), and then populates them into the user’s certificate store (MYSTORE).
-
CSP to smart card resource manager communication happens on LRPC Channel.
-
On successful authentication, certificates will be propagated to the user’s store (MYSTORE) asynchronously by the Certificate Propagation Service (CertPropSvc).
-
When the card is removed, certificates in the temporary secure cache store are removed. The Certificates are no longer available for logon, but they will remain the user’s certificate store (MYSTORE).
Note |
|---|
|
A SID is a security identifier that is created for each user or group, at the time a user account or a group account is created within either the local security accounts database on Windows NT or higher computers, or within Active Directory. The SID never changes, even if the user or group account is renamed. |
For more information about Kerberos, see How the Kerberos Version 5 Authentication Protocol Works (http://go.microsoft.com/fwlink/?LinkID=27175).
By default, the KDC verifies that the client's certificate contains the smartcard client authentication EKU szOID_KP_SMARTCARD_LOGON. However, there is a policy that allows the KDC not to require the SC-LOGON EKU (SCLogonEKUNotRequired – See Table 7). SC-LOGON EKU is not required for account mappings that are based on the public key.
KDC certificate
Active Directory Certificate Services provides three kinds of certificate templates:
-
Domain controller
-
Domain controller authentication
-
Kerberos authentication (new in Windows Server® 2008)
Depending on the configuration of the domain controller, one of these types of certificate is sent as a part of the AS_REP packet. For more information on certificate templates, see Active Directory Certificate Server Enhancements in Windows Server 2008 (http://go.microsoft.com/fwlink/?LinkId=83212).
Client certificate mappings
Certificate mapping is based on the UPN that is contained in the subjectAltName (SAN) field of the certificate. Client certificates that do not contain the subjectAltName extension in the certificate are also supported.
SSL/TLS can map certificates that do not have SAN, and the mapping is done using the AltSecID attributes on client accounts. The X509 AltSecID used by SSL/TLS client authentication is of the form "X509:<I>"<Issuer Name>"<S>"<Subject Name>. Here the <Issuer Name> and <Subject Name> are taken from the client certificate, with '\r' and '\n' replaced with ','.
Figure 17 CRL distribution points
Figure 18 UPN in Subject Alternative Name field
Figure 19 Subject and Issue fields
This account mapping is to be supported by the KDC. The KDC also supports six other mapping methods. The following figure shows a flow of user account mapping logic used by KDC.
Figure 20 High-level flow of certificate processing for logon
The certificate object is parsed to look for certain contents to perform user account mapping. When a user name is also provided with the certificate, then the user name is used to locate the account object. This operation is the fastest, because string matching occurs. When only the certificate object is provided, then a series of operations are performed to locate the user to map the user to an account object. When no domain information is available for authentication, the local domain is used by default. If any other domain is to be used for lookup, then a domain name hint should be provided to perform the mapping and binding. Mapping based on generic attributes is not possible, because there is no generic API to retrieve attributes from a certificate.
Currently, the first method that locates an account successfully wins, and the search stops. But if two mapping methods map the same certificate to different user accounts when the client does not supply the client name via the mapping hints, then it is a configuration error.
For more information on mapping certificates to user accounts, see Deploying a Public Key Infrastructure (http://go.microsoft.com/fwlink/?LinkId=93737).
Figure 21 illustrates the process of mapping user accounts for logon in the directory by looking at various entries in the certificate. NT_AUTH policy is best described in CertVerifyCertificateChainPolicy (http://go.microsoft.com/fwlink/?LinkId=93738) under CERT_CHAIN_POLICY_NT_AUTH.
Figure 21 Certificate processing logic
Smart card logon of a single user with one certificate into multiple accounts
A single user certificate can be mapped to multiple accounts. For example, a user might be able to log on to his user account and also to log on as a domain administrator. The mapping is done using the constructed AltSecID based on attributes from client accounts. See Client Certificate Mappings on how this mapping is evaluated.
Note |
|---|
|
Because each account has a different user name, we recommend that you enable the X509Hints Group Policy Object to provide the user information for whom he/she will want to login as. |
The following lists the conditions for logon, based on the certificate contents:
-
If no UPN is present in the certificate:
-
Logon can happen in the local forest or in another forest if a single user with one certificate needs to logon to different accounts.
-
A hint must be supplied if mapping is not unique (more than one user mapped to the same certificate).
-
If a UPN is present in the certificate:
-
The certificate cannot be mapped to multiple users in the same forest.
-
The certificate can be mapped to multiple users in different forests. In order to logon user in other forests, an X509 hint must be supplied to the user.
Smart card logon of multiple users into a single account
A group of users might log on to a single account (for example, an administrator account). For that account, user certificates are mapped so that they are enabled for logon.
Several distinct certificates can also be mapped to a single account (for this to work properly, the certificate cannot have UPNs).
For example, if Certificate1 has CN=CNName1, Certificate2 has CN=User1, and Certificate3 has CN=User2, then the AltSecID of these certificates can be mapped to a single account by using the Active Directory Users and Computers Name Mapping.
Smart card logon across forests
In order for account mapping to work across forests, especially in cases where not enough information is available on the certificate, the user might enter a hint (in the form of a user name such as Domain\User or a fully qualified UPN such as User@DNSNameOfDomain.com).
Note |
|---|
|
For the hint field to appear during smartcard logon, the X509HintsNeeded registry key must be set on the client to enable display of an additional hints field to the logon UI with the PIN field (see Table 7). |
OCSP support for PKINIT
Online Certificate Status Protocol (OCSP), defined in RFC 2560, enables applications to obtain timely information about a certificate's revocation status. Because OCSP responses are small and well bounded, constrained clients might want to use OCSP to check the validity of the certificates for Kerberos KDC, in order to avoid transmission of large certificate revocation lists (CRLs) and save bandwidth on constrained networks.
Microsoft’s KDC will always try to get the OCSP responses and use them when available. There is no policy that can be used to turn that off. CAPI2 APIs for OCSP caches OCSP responses and the status of the responses. KDC only supports OCSP response for signer certificate.
Windows clients will always try to request the OCSP responses and use them in the reply, when they are available. There is no policy that can be used to turn that off.
Certificate revocation support
Table 12 itemizes the keys and the corresponding values to turn off CRL checking (on the wire) at the KDC or client. Both settings are required.
Table 12 CRL checking registry keys
|
Key
|
Description
|
| HKLM\SYSTEM\CCS\Services\Kdc\UseCachedCRLOnlyAndIgnoreRevocationUnknownErrors | Type = DWORD Value = 1 |
| HKLM\SYSTEM\CCS\Control\LSA\Kerberos\Parameters\UseCachedCRLOnlyAndIgnoreRevocationUnknownErrors | Type = DWORD Value = 1 |
Smart card root certificate requirements for use with domain join
There are some specific conditions that the smart card certificate must meet in order for smart card-based domain join to work.
-
Smart card certificate must contain a Subject field that contains the DNS domain name in the DN. If it does not, then resolution to appropriate domain will fail, and TS and domain join with smartcard will fail.
OR
-
Smart card certificate must contain a UPN where the domain part of the UPN must resolve to the actual domain. For example, UPN "username@engineering.corp.contoso.com" would work, but "username@engineering.contoso.com" would not work, because the Kerberos client would not be able to find the appropriate domain.
The workaround is to supply a hint (enabled via GPO setting X509HintsNeeded as specified in Table 7) in the credentials user interface for domain join.
If the client computer is not joined to the domain (or if it is joined to a different domain), then the client will be able to resolve the server domain only by looking at the DN on the certificate (not the UPN). For this scenario to work, the certificate needs a full Subject (including “DC=…”) for domain name resolution.
To deploy root certificates on smart card for the currently joined domain, you can use the following command:
certutil –scroots