Active Directory Certificate Services

Active Directory Certificate Services (ADCS) is rough to work with when things don’t behave correctly. This article will cover everything you need to be conversational (read: complain to sysadmins) about ADCS.

Introduction to Certificates

When working with more than a handful of machines, it becomes essential to have a scalable framework for reputation and trust. ADCS is deployed when you need a centralized and reputable/trustworthy topology for encryption (in the form of certificates). When using ADCS, you will have servers operating as a Certificate Authority (CA). As part of the implementation process, you will tell relevant devices about the CA(s) and inherently trust them.  

Certificate Authorities enable the Internet to securely provide access to services using encrypted protocols like Secure Socket Layer (SSL).

In the early days of the internet, files and communications were plain text (unencrypted). There were fewer malicious individuals then, and the Internet was a much smaller place. While not ideal, your PC broadcasting confidential information everywhere did not present the same concerns that it does today. 

Before encryption technologies like SSL, when a client connected to a server, it would use a protocol like HTTP, FTP, Telnet, SMB1, SNMP1, etc. These protocols communicated over the network by essentially sending text files between client and server. Every other machine on that network could observe these communications and read the text files being exchanged. It might not be a big deal if someone overhears a happy birthday email, but overhearing the authentication for a bank account presents a bigger concern. 

Securing Communications

One way to obfuscate the contents of your communication is to speak in a foreign language that anyone listening doesn’t know. Essentially, encryption does the same to data protected by SSL.  

Now, when a client is connected to a server it might use a protocol like HTTPS, FTPS/VSFTP/SCP, SSH, SMB3, SNMP3, etc. These protocols communicate over the network by sending encrypted files written in a made-up language that only the client and server know about. The ‘made up language’ in this case is the SSL certificate.  

Functions of a Certificate

SSL certificates provide the identity of a domain name (ex. google.com) and what authority is willing to validate this identity. You can view the SSL certificate of a website in your web browser (process varies, just google how to do this) or in a terminal with the openssl package: openssl s_client -connect github.com:443 -showcerts

Example Certificate for github.com:

Regardless of if you view the certificate in your browser, terminal, or the certificate manager in your OS, you will see the same content:  

Negotiation Data
  • Identity of the intended recipient
  • List of CA’s in the approval process
  • Validity start and end dates
Supplemental Data
  • Organization information
  • Optional metadata
  • How this certificate can be used

The list of CA’s in the approval process is called a certificate chain, chain of trust, or certificate hierarchy. It will provide a tree view of the Root CA and Intermediate CA(s) involved in signing this certificate.

All root and intermediate CAs in the chain must be trusted by a device for the certificate to be trusted.

Deploying Active Directory Certificate Services

There are many ways to set up different CA topologies, but using ADCS is one of the easiest and most common methods. If you leverage AD a lot in your environment, then using ADCS for your CA’s could make sense.

ADCS is fairly simple to set up and administer, but as a result, it is not very feature-rich and tends to be very bare bones. Another thing to remember is that the more things you integrate with AD, the more vulnerabilities you are introducing into the core of your environment.

It is catastrophic if a malicious party compromises an AD root CA, as they now own the entire AD environment. It is not uncommon within an enterprise topology for a root CA to be a non-AD-integrated machine that is powered off at all times except when undergoing maintenance and updates.  

Initial Setup

We will build an AD-integrated root CA and not worry about setting up a multiple CA topology. Before you add anything, make sure the server is joined to your AD.
Use the Windows Server Manager to add the Active Directory Certificate Services role. I typically enable the option for web enrollment but any configuration is fine for this demo.

After you complete the installation, click the ADCS notification in the server manager.

Callouts for the configuration wizard:

  • If you installed other services during the install (web enrollment) do not check the boxes yet. 
  • Choose the options to set it up as an ‘Enterprise CA’ and a ‘root CA’
  • Create a new private key and leave the default at RSA 2048

Using the Certificate Server

Open the Certificate Services application to interact with the CA.

There are only a few places that you will likely go in your time using ADCS.
 
If you left-click on the name of your CA in the navigation column and then right-click it, you will get a selection menu. Hover over ‘All tasks’ with your mouse.  
  • The most common thing you will do is ‘submit a new request’; this is where you upload a CSR/REQ/DER file, and the CA will provide you a signed certificate.  
  • If you ‘Backup CA …’ it will export a list of all certs in the CA as well as the records for the CA itself. 

Other common operations:

  • To see signing requests from AD & IIS you can click ‘Pending Requests’.
  • The CA keeps a record of anything it has signed in the ‘Issued Certificates’ 

Integrating Certificate Authorities

Active Directory will not automatically tell AD joined PC’s about the new root CA/Subordinate CA. For AD-joined devices, you can use Group Policy Objects to save certificates to the local ‘trusted store.’ You will need to get the public certificate (.cer) of each CA in the certificate chain and import it into AD.

Certificate Server

  1. Login to the root CA you configured earlier
  2. Open the Certificate Services MMC
  3. Right click on the root CA in the navigation pane
  4. Hover over ‘All Tasks’ and click ‘Backup CA’ and click ‘Next’
  5. Check the box for ‘Private key and CA certificate’
  6. Click the ‘Browse’ button and navigate to the Downloads directory
  7. In the filepath to the left of browse, add a ‘\tmp\’ after the ‘\Downloads’
  8. Click ‘OK’ on the dialogue box asking if you want to make the \tmp\ directory
  9. Use a good password on the following prompt to encrypt the file
  10. Click ‘Finish’ to complete the export to a .PFX file

If you installed an intermediate CA, you will need to repeat steps 1-9 for each CA in the chain.

Domain Controller

  1. Login to one of your domain controllers
  2. Copy the .PFX file from the previous step to the DC
  3. Open the Group Policy MMC
  4. Create a new GPO or edit an existing one as makes sense
  5. Navigate to
    Computer Configuration -> Policies -> Windows Settings -> Security Settings -> Public Key Policies
  6. Right click on the ‘Trusted Root Certification Authorities’ container/folder and click Import
  7. Click ‘Browse’ and select the .PFX file from the previous step and click ‘Next’
  8. Put in the password you used to encrypt the file
    Do not check the box to make the key exportable
    Check the box to Include all extended properties
  9. Click ‘Next’ and ‘Finish’

If you installed an intermediate CA, right click on the ‘Intermediate Certification Authorities’ container/folder and click Import. You must repeat steps 1 – 8 for each CA in the chain.

Article Summary

For a machine to trust a website using SSL, it must ‘trust’ the certificate the website is using. At minimum, there will be one Certificate Authority that signs a certificate (like a CEO signing approval on a document), but usually, there is more than one Certificate Authoritie signing a document (The CEO has authorized the CFO to sign a document with the CEO’s authority). For a machine to trust that certificate it must trust every certificate authority listed in the certificate chain.  

Article Appendix

I am trying out the concept of an appendix and hitting some tangential things that don’t fit in the article. Let me know your thoughts on this.

Definitions

Terms
  • Certificate – File that encrypts communication or data (aka public key certificate)  
  • Encryption – Process that results in altered data that can only be restored by knowing the algorithm and password used to change it
Certificate Files
  • PKCS7 – Public Key Certificate System #7, an all-encompassing certificate that contains a public key and a private key  
  • PFX – Personal Information Exchange, synonomous with PKCS7  
  • CER – Certificate file (synonomous with DER or PEM files), binary format with no private key  
  • CSR – Certificate Signing Request, file that contains a hosts public key and is submitted to a CA for signing  
  • REQ – Certificate Request, file that contains a hosts public key and is submitted to a CA for signing
Protocols
  • SSL – Secure Socket Layer, a protocol that encrypts data  
  • TLS – Transport Layer Security, successor to SSL and is a protocol that encrypts data
    TLS is often referred to as SSL even though they are different protocols
  • HTTP, FTP, Telnet, SMB1, SNMP1 – unencrypted communication protocols referenced in this article  
  • HTTPS, FTPS/VSFTP/SCP, SSH, SMB3, SNMP3 – encrypted communication protocols referenced in this article  
Certificate Authorities
  • CA – Certificate Authority, entity that signs certificates  
  • Root CA – Root Certificate Authority, the highest level of CA and the CA that authorizes other CAs to sign certificates  
  • Intermediate CA – aka subordinate CA. Intermediate Certificate Authority, a CA approved by the root CA to sign certificates on behalf of the root CA  
Unused terms (explained more in a future article)
  • RSA – Mathematical algorithm that encrypts/decrypts data using a public/private key pair
  • Wildcard – Way to include every variation of a domain with a single definition (ex. *.google.com)
  • PKI – Public Key Infrastructure, the system or framework you use to store/manage/approve/revoke/issue certificates  
  • OCSP – Online Certificate Status Protocol, used in tandem with CRLs to determine the validity of an issued certificate  
  • SCEP – Simple Certificate Enrollment Protocol, way to request a certificate for non AD devices (ex. switches)
  • Public Key – used to encrypt data, cannot decrypt any encrypted data  
  • Private Key – used to decrypt data, cannot encrypt any data  
  • CRL – Certificate Revocation List, list of revoked certificates that all CA’s in the PKI must be agree (sync) on  

Troubleshooting SSL

Check if OSCP thinks example.pem is revoked  
  ‘openssl ocsp -issuer issuer_cert.pem -cert example.pem -text -url http://ocsp.responder.url’  
Print a certificate file to the console  
  ‘openssl x509 -in certificate.crt -text -noout’  
Print a certificate from a website to the console  
  ‘openssl s_client -connect example.com:443 -showcerts’  

Submit a request via AD to a CA  
  ‘certreq -submit -attrib “CertificateTemplate:SubCA” C:/Users/example/Downloads/example.cer’  
Check all CRL references for the local CA certificate  
  ‘certutil -verify -urlfetch myCACertificate.crt’  
Flush CRL cache on a CA  
  ‘certutil -urlcache * delete’  
Manually pull CRL from another CA  
  ‘certutil -url [CRL URL]’  
Output CRL to console  
  ‘certutil -dump example.crl’  
Verbose output of CRL download  
  ‘certutil -URLcache CRL http://example.example/certenroll/example.crl’  
Add a new Root CA using cert file  
  ‘certutil -addstore “Root” newRootCA.crt’

Export Public Key

1. Open the Certificate Services MMC
2. Right click on the root CA in the navigation pane and click ‘properties’
3. The ‘General’ tab will open, click ‘view certificate’
4. Click the details tab on the following menu
5. Select ‘copy to file’
6. Use DER encoded binary and proceed by clicking ‘Next’
7. Click ‘Browse’ and navigate to your target directory (if temporary I use Downloads)
8. Type your file name in the dialog box and click ‘Save’ followed by ‘Next’ and ‘Finish’