Hi, since I am working with Windows PKI (10+ years) I noticed that a Windows CA is running into a situation where the CRL has expired and the CA service will never renew it until you force it to do.
That happens if the CA is down for maintenance or restore right at the time the renew of the CRL would be triggered. So that is bad but only things we cannot change keep us awake at night and so here is the solution for that problem.
I recommend to issue the CRL e.g. for issuing CAs with a validity between 10 and 14 days, no longer and definitely not much shorter until you are 110 percent sure about you recovery process and you have tested it in real before. I had once a client they promised to have any machine recovered within 4 hours. We had a bad hard drive or controller and one came to the other. We asked for a recovery what happened 4 days later. Okay so if your CRL is to short you get a lot of pressure at this point.
As in any good PKI project you can ask certutil.exe for help.
A certutil.exe -CRL command triggers the CA to issue a new CRL. Depending on your configuration that file goes into LDAP and/or on the file system. With certutil.exe -getcrl myCAcrlfile.crl you get it from the CA as well e.g. in case you want copy it to multiple web servers.
That can do a scheduled tasks e.g. executed once a day or night
So that gives us some advantages:
1) we see every day a new CRL (like a heartbeat ;-))
2) the new CRL has always the max validity period
3) is contains the latest revoked certificates, if any
4) even the CA was down for maintenance at the point of CRL renewal, the schedule task will take care of the CRL renewal
If you make use of certificate revocation a lot that is also the way to trigger the CA to issue new CRLs more often. Just run it more often.
Until next time,
Lutz
Showing posts with label PKI. Show all posts
Showing posts with label PKI. Show all posts
Friday, April 1, 2016
Thursday, March 31, 2016
certutil.exe shortcut
Hi,
currently I am working with great people on a PKI project. So it came how it has to come, we use certutil.exe for various purposes and we came across a nice shortcut I want share.
So every time you use certutil.exe to query a CA server from remote you have to specify the config information. (Actually the -ping allows you just to specify the CA hostname, no -config necessary)
e.g.
C:\system>certutil.exe
Entry 0:
Name: `AAA-trii-CAI01'
Organizational Unit: `'
Organization: `tribaldi'
Locality: `'
State: `'
Country/region: `'
Config: `cai01.tribaldi.net\AAA-trii-CAI01'
Exchange Certificate: `'
Signature Certificate: `'
Description: `'
Server: `cai01.tribaldi.net'
Authority: `AAA-trii-CAI01'
Sanitized Name: `AAA-trii-CAI01'
Short Name: `AAA-trii-CAI01'
Sanitized Short Name: `AAA-trii-CAI01'
Flags: `1'
Web Enrollment Servers: `'
CertUtil: -dump command completed successfully.
So then you copy the config value and use it like:
C:\system>certutil -catemplates -config "cai01.tribaldi.net\AAA-trii-CAI01"
3b_clmAgent: 3b_clmAgent -- Auto-Enroll: Access is denied.
3B_enrollment_agent: 3B_enrollment_agent -- Auto-Enroll: Access is denied.
3BUser_onbehalf: 3BUser_onbehalf -- Auto-Enroll: Access is denied.
WebServerORG: Web Server ORG -- Auto-Enroll: Access is denied.
3bcomputer: 3bcomputer -- Auto-Enroll: Access is denied.
ISE_BYOD: ISE_BYOD -- Auto-Enroll: Access is denied.
BYOD: BYOD -- Auto-Enroll: Access is denied.
WebServer: Web Server -- Auto-Enroll: Access is denied.
IPSECIntermediateOffline: IPSec (Offline request) -- Auto-Enroll: Access is denied.
CEPEncryption: CEP Encryption -- Auto-Enroll: Access is denied.
EnrollmentAgentOffline: Exchange Enrollment Agent (Offline request) -- Auto-Enroll: Access is denied.
CertUtil: -CATemplates command completed successfully.
So while that is cool for scripting purpose, e.g. for documentation, the shortcut is much simpler. Instead of the value behind the config parameter you can just type a dash (minus sign), and that will open a dialog showing you all CA registered in AD. See here
P.S. these examples are created from Windows 2012 R2 machines.
currently I am working with great people on a PKI project. So it came how it has to come, we use certutil.exe for various purposes and we came across a nice shortcut I want share.
So every time you use certutil.exe to query a CA server from remote you have to specify the config information. (Actually the -ping allows you just to specify the CA hostname, no -config necessary)
e.g.
C:\system>certutil.exe
Entry 0:
Name: `AAA-trii-CAI01'
Organizational Unit: `'
Organization: `tribaldi'
Locality: `'
State: `'
Country/region: `'
Config: `cai01.tribaldi.net\AAA-trii-CAI01'
Exchange Certificate: `'
Signature Certificate: `'
Description: `'
Server: `cai01.tribaldi.net'
Authority: `AAA-trii-CAI01'
Sanitized Name: `AAA-trii-CAI01'
Short Name: `AAA-trii-CAI01'
Sanitized Short Name: `AAA-trii-CAI01'
Flags: `1'
Web Enrollment Servers: `'
CertUtil: -dump command completed successfully.
So then you copy the config value and use it like:
C:\system>certutil -catemplates -config "cai01.tribaldi.net\AAA-trii-CAI01"
3b_clmAgent: 3b_clmAgent -- Auto-Enroll: Access is denied.
3B_enrollment_agent: 3B_enrollment_agent -- Auto-Enroll: Access is denied.
3BUser_onbehalf: 3BUser_onbehalf -- Auto-Enroll: Access is denied.
WebServerORG: Web Server ORG -- Auto-Enroll: Access is denied.
3bcomputer: 3bcomputer -- Auto-Enroll: Access is denied.
ISE_BYOD: ISE_BYOD -- Auto-Enroll: Access is denied.
BYOD: BYOD -- Auto-Enroll: Access is denied.
WebServer: Web Server -- Auto-Enroll: Access is denied.
IPSECIntermediateOffline: IPSec (Offline request) -- Auto-Enroll: Access is denied.
CEPEncryption: CEP Encryption -- Auto-Enroll: Access is denied.
EnrollmentAgentOffline: Exchange Enrollment Agent (Offline request) -- Auto-Enroll: Access is denied.
CertUtil: -CATemplates command completed successfully.
So while that is cool for scripting purpose, e.g. for documentation, the shortcut is much simpler. Instead of the value behind the config parameter you can just type a dash (minus sign), and that will open a dialog showing you all CA registered in AD. See here
And that will give you exact the same result as in the command before.
Until next time,
Lutz
P.S. these examples are created from Windows 2012 R2 machines.
Monday, November 17, 2014
How to archive and un-archive certificates
You are might aware that certificates can be flagged archived on a Windows machine. That has nothing (as in nada) to do with key archiving what is performed if configured on the Certification Authority.
The archive flagged is used to make certificates invisible to applications without deleting them from a user or machine store. E.g. auto-enrollment sets this flag to an certificate if a new certificate has been enrolled.
In this post I want show you how to set and unset this flag.
First of all we want see if we have a certificate in the certificate store with the archive flag set. I work on my machine as local administrator and so should you.
1. Open for that a MMC and add the Certificate snap-in for either your user or the local machine, or both if you like.
Then enable show archived certificates. That is like an advanced view setting that you might know from Active Directory Users and Computers.
Note: You have to enable the Archived certificate view for each snap-in separately. So in the picture above I made that for Certificates - Current user and for Certificates (Local Computer)
Now you see archived certificates in the MMC
Note the letter A at the end. That is the sign that this certificate is flagged archived.
2. You can do the same by running a certutil command. The MMC does not give you an option to set the flag from there. So you have to use certutil to do that, see below.
Use certutil to see all certificates
certutil.exe -store my
will show you all certificates in the local machine store
...
================ Certificate 4 ================
Archived!
Serial Number: 3dc344f3e2cf6dab48d7085ecd1bb849
Issuer: CN=localhost
NotBefore: 6/13/2012 2:17 PM
NotAfter: 6/12/2022 5:00 PM
Subject: CN=localhost
Signature matches Public Key
Root Certificate: Subject matches Issuer
Template:
Cert Hash(sha1): 80 3e 7f 62 5a be 5b 14 52 e3 65 dd 72 4d 59 98 cb 8a 30 d3
Key Container = IIS Express Development Certificate Container
Unique container name: fad662b360941f26a1193357aab3c12d_42f2ea6e-c662-4d0b-8b56-2f094a3a3dc9
Provider = Microsoft RSA SChannel Cryptographic Provider
Encryption test passed
....
So that certificate is number 4 in the certificate store. Lets write this down for later.
3. We will use certutil for un-archiving the certificate (and we can use it for archiving as well).
Here the file to set the archive flag.
- Create a new file with notepad and call it archive_set.inf
- paste these two lines to the archive_set.inf file
[Properties]
19 = Empty ;
Here the file to remove the archive flag
- Create a new file with notepad and call it archive_remove.inf
- paste these 2 lines to the archive_remove.inf file
[Properties]
19 = ;
4. Now you can toggle the archive flag as you desire:
Now you need the number you have taken down from step 2 or use the certificate serial number instead.
flag on
certutil.exe -repairstore my 4 archive_set.inf
flag off
certutil.exe -repairstore my 4 archive_remove.inf
See also http://blogs.technet.com/b/pki/archive/2007/02/22/how-to-manually-set-the-archive-flag-for-certifictes.aspx
The archive flagged is used to make certificates invisible to applications without deleting them from a user or machine store. E.g. auto-enrollment sets this flag to an certificate if a new certificate has been enrolled.
In this post I want show you how to set and unset this flag.
First of all we want see if we have a certificate in the certificate store with the archive flag set. I work on my machine as local administrator and so should you.
1. Open for that a MMC and add the Certificate snap-in for either your user or the local machine, or both if you like.
Then enable show archived certificates. That is like an advanced view setting that you might know from Active Directory Users and Computers.
Note: You have to enable the Archived certificate view for each snap-in separately. So in the picture above I made that for Certificates - Current user and for Certificates (Local Computer)
Now you see archived certificates in the MMC
Note the letter A at the end. That is the sign that this certificate is flagged archived.
2. You can do the same by running a certutil command. The MMC does not give you an option to set the flag from there. So you have to use certutil to do that, see below.
Use certutil to see all certificates
certutil.exe -store my
will show you all certificates in the local machine store
...
================ Certificate 4 ================
Archived!
Serial Number: 3dc344f3e2cf6dab48d7085ecd1bb849
Issuer: CN=localhost
NotBefore: 6/13/2012 2:17 PM
NotAfter: 6/12/2022 5:00 PM
Subject: CN=localhost
Signature matches Public Key
Root Certificate: Subject matches Issuer
Template:
Cert Hash(sha1): 80 3e 7f 62 5a be 5b 14 52 e3 65 dd 72 4d 59 98 cb 8a 30 d3
Key Container = IIS Express Development Certificate Container
Unique container name: fad662b360941f26a1193357aab3c12d_42f2ea6e-c662-4d0b-8b56-2f094a3a3dc9
Provider = Microsoft RSA SChannel Cryptographic Provider
Encryption test passed
....
So that certificate is number 4 in the certificate store. Lets write this down for later.
3. We will use certutil for un-archiving the certificate (and we can use it for archiving as well).
Here the file to set the archive flag.
- Create a new file with notepad and call it archive_set.inf
- paste these two lines to the archive_set.inf file
[Properties]
19 = Empty ;
- save the file
Here the file to remove the archive flag
- Create a new file with notepad and call it archive_remove.inf
- paste these 2 lines to the archive_remove.inf file
[Properties]
19 = ;
- save the file
4. Now you can toggle the archive flag as you desire:
Now you need the number you have taken down from step 2 or use the certificate serial number instead.
flag on
certutil.exe -repairstore my 4 archive_set.inf
flag off
certutil.exe -repairstore my 4 archive_remove.inf
See also http://blogs.technet.com/b/pki/archive/2007/02/22/how-to-manually-set-the-archive-flag-for-certifictes.aspx
Sunday, November 10, 2013
Creating a IPSEC tunnel with the Windows Firewall with Advanced Security
Windows provides a very simple way to establish a secure communication (IPSEC) between two machines on the machine level: Connection Security Rules.
Connection Securiy Rules allow the configuration of a encrypted communication even a user is not logged on. The IPSEC rule can use a preshared key (for testing, single server or you do not have a PKI) or digital certificates for authentication in an enterprise environment Using certificates is the best way for authentication and my recommendation.
The computer and the users have still to authenticate before they can use any service on a IPSEC protected host, so see IPSEC as an pre-authentication.
Use scenarios:
- You want allow only access from corporate laptop computers to Exchange Outlook Anywhere or other internal services directly, or over TMG or UAG
- You have a server externally hosted and you want have a more secure way to RDP in
- You want allow access to a file share for remote workers in a way they do not have to VPN-in all the time
- You want make sure that computers for remote worker can use the corporate WSUS server for patching even the machines are not connected back via VPN to corporate network
- ...
Requirement:
- Windows Firewall service must be running
- Windows Firewall profiles must be active the network profile(s)
- Firewall rules must allow IPSEC traffic ESP and UDP500(ISAKMP). UDP4500(IPSEC NAT-T) is required if the server is behind a NAT firewall (as it is in this example)
Note: You can require IPSEC also only for certain TCP ports, e.g. you have an externally hosted web server. Require IPSEC only for 3389(RDP) for web server administration but port 80 is open because you clients want surf your companies public web site.And make all other ports not available from outside of that server at all.
Client Configuration Steps
1.
Open Group Policy Management
2.
Navigate to Computer
Configuration/Policies/Windows Settings/Security Settings/Windows Firewall with
Advanced Security/ Windows Firewall with Advanced Security/Connection Security
Rules
Note: as alternative and
for testing you can also start the Windows Firewall management console by starting
wf.msc from the Run dialog.
3.
Make a right mouse click on Connection Security
Rules and click on New Rule…
4. Select Server-to-server as rule type and click Next.
5. Add the public IP address of the edge server to
the list of IP addresses under “Which computers are in Endpoint 2?” Then select
Next to continue.
6.
Select and then click Next.
7. Click
Browse and select the appropriate CA name. Then click Next.
8. Select all firewall profiles and click Next.
9. Enter
name and description of the rule. Then click Finish to end the configuration wizard.
Server Side Configuration Steps
The server must have a second network card for external
facing connections. The configuration of the IPSEC rules should be for this
interface, otherwise you might lose the network connection to the server.
1. Start the Windows Firewall Advanced
Configuration management console from the Run menu by running wf.msc.
2. Click
on Connection Security Rules and then New
Rule …
3. Select
Server-to-server and click Next.
4. Add
the server IP address to the list of IP address under “Which computers are in
Endpoint 2?” and click Next to
continue.
5. Select
Require authentication for inbound and outbound connections and then click on Next.
6. Click
Browse and select the appropriate CA name. Then click Next.
7. Select all firewall profiles and click Next.
Friday, August 30, 2013
Bitlocker Data Recovery Agent Certificate
Microsoft BitLocker supports Data Recovery Agents in Windows 7 and above.
That is a great way for large organizations to ensure that the corporate IT or Information Security has access to data for if the individual pass-phrase recovery is not working and for forensics.
To setup a Data Recovery Agent you can follow Microsofts blog post http://blogs.technet.com/b/askcore/archive/2010/10/11/how-to-use-bitlocker-data-recovery-agent-to-unlock-bitlocker-protected-drives.aspx
If you do not see the BitLocker Drive Encryptin and BitLocker Data Recovery Agent extended key usage (EKU) listed in the GUI install the BitLocker feature on your management machine. Even feature installation does not require a reboot, you will not see the EKU showing up in the last until you do so.
If you Certification Authority is running on Windows 2003 you have to add the EKUs manually. For this you need the OIDs, here you go.
That is a great way for large organizations to ensure that the corporate IT or Information Security has access to data for if the individual pass-phrase recovery is not working and for forensics.
To setup a Data Recovery Agent you can follow Microsofts blog post http://blogs.technet.com/b/askcore/archive/2010/10/11/how-to-use-bitlocker-data-recovery-agent-to-unlock-bitlocker-protected-drives.aspx
If you do not see the BitLocker Drive Encryptin and BitLocker Data Recovery Agent extended key usage (EKU) listed in the GUI install the BitLocker feature on your management machine. Even feature installation does not require a reboot, you will not see the EKU showing up in the last until you do so.
If you Certification Authority is running on Windows 2003 you have to add the EKUs manually. For this you need the OIDs, here you go.
Bitlocker Drive Encryption - 1.3.6.1.4.1.311.67.1.1
Bitlocker Data Recovery Agent - 1.3.6.1.4.1.311.67.1.2
Saturday, July 27, 2013
Error opening SSL protected web sites running on IIS from a Windows XP computer
Recently I have experienced an error accessing a HTTPS web site using Internet Explorer 8. Even this is not the most current setup I thought I should share what happened.
1. A SSL certificate is installed on the Windows Server and is configured in IIS on the default web site or any other web site you have.
2. The client is a Windows XP machine and you use Internet Explorer to access the web site. (The problem does not occur if you use Chrome or Firefox.)
3. The problem: IE reports a "Internet Explorer cannot display the webpage" immediately when you try to access the web site. This is the same message you see if the web site or server does not exist or the DNS name cannot be resolved.
4. Accessing the same web site from Windows 7 using Internet Explorer works with no issues.
So what is wrong?
To investigate the problem I used Fiddler and the information from the server's event log that the browser and the web server could not found a common encryption cipher.
Because the server was just using the default settings I thought it would be good to verify the local machine's certificate store.
So I run a certutil.exe -store my on the server and I found out that the SSL certificate was installed using the Microsoft Strong Cryptographic provider. So I exported it and I have imported it using the certutil.exe -importpfx command to the Microsoft RSA SChannel Cryptographic Provider CSP. After that the access from the XP machines worked again.
btw: Qualys runs a free service with a excellent test drive for SSL web sites (including explanations what and why to configure) at https://www.ssllabs.com/ssltest/
1. A SSL certificate is installed on the Windows Server and is configured in IIS on the default web site or any other web site you have.
2. The client is a Windows XP machine and you use Internet Explorer to access the web site. (The problem does not occur if you use Chrome or Firefox.)
3. The problem: IE reports a "Internet Explorer cannot display the webpage" immediately when you try to access the web site. This is the same message you see if the web site or server does not exist or the DNS name cannot be resolved.
4. Accessing the same web site from Windows 7 using Internet Explorer works with no issues.
So what is wrong?
To investigate the problem I used Fiddler and the information from the server's event log that the browser and the web server could not found a common encryption cipher.
Because the server was just using the default settings I thought it would be good to verify the local machine's certificate store.
So I run a certutil.exe -store my on the server and I found out that the SSL certificate was installed using the Microsoft Strong Cryptographic provider. So I exported it and I have imported it using the certutil.exe -importpfx command to the Microsoft RSA SChannel Cryptographic Provider CSP. After that the access from the XP machines worked again.
btw: Qualys runs a free service with a excellent test drive for SSL web sites (including explanations what and why to configure) at https://www.ssllabs.com/ssltest/
Friday, May 31, 2013
PowerShell script to enhance the Windows CA SMTP exit module
Windows CA SMTP exit module
the Windows Certification Authority has a built in feature (Windows Enterprise SKU) to send out emails to inform the PKI administrators if a new pending certificate request waiting for approval or if a new certificate has been issued. Just 2 examples.
The configuration must be done in the registry: See here for an example
http://social.technet.microsoft.com/wiki/contents/articles/2004.active-directory-certificate-services-smtp-exit-module-for-windows-server-2008-r2-example.aspx
Unfortunately you cannot configure it to send the issued certificate to the certificate requestor. For that I wrote a PowerShell script what is also working with the Windows Server 2008 R2 Standard Server.
Config file - sendcert_inc.ps1:
$sendcertpath=".\sendcert"
$msgFrom='noreply@frontoso.com'
$smtphost='127.0.0.1'
$certtmpl="1.3.6.1.4.1.311.21.8.5245527.10310595.8014498.11013764.15833798.137.13192380.4508386" #CorpWebServer
$certfileExt="txt" # fyi: extensions cer and der are blocked by Outlook
$mailbody="mailbody.txt"
$dbscanperiod="03:00" # 01:00 = 1 day, 1:15 = 1 day 15 hours; $dbscanperiod is the max time (now - $dbscanperiod) sendcert goes back in the certificate database, e.g. useful if you have already issued certs for years and you going to enable sendcert now
Mailbody.txt
Hello, attached is the requested certificate.
Please download the certificate and proceed with the SSL/TLS setup of your application.
For your convenience the certificate can be found as attachment and in the mail body.
Thank you,
----------------------------------------------------------------------------
Do not reply to this message. It was sent from an unmonitored email account.
sendcert.ps1
#
# Author: lutz.mueller-hipper@tribaldi.net
# Updates: lutz.mueller-hipper@insight.com
# Date: May 23, 2013 - v3.1
#
clear
import-module ActiveDirectory
# if not yet installed please install the ActiveDirectory PowerShell module
#dism /online /enable-feature /featurename:ActiveDirectory-PowerShell
if (-not (Test-Path .\sendcert_inc.ps1))
{
write-host "Error: sendcert_inc.ps1 configuration file not found." >>sendcert.log
exit;
} else {
. .\sendcert_inc.ps1
}
if (-not (Test-Path $sendcertpath)) { mkdir $sendcertpath >$null}
$Arr_SendCert = @()
write-host "=========================="
write-host Start Send certificate via email to certificate requestor
write-host "=========================="
write-host
#Disposition Description
#20 certificate was issued
#21 certificate is revoked
#30 certificate request failed
#31 certificate request is denied
$reqid_db = @()
$reqid_db = get-content $sendcertpath\reqid_do_not_remove.txt
$reqid_db2 = @()
foreach ( $line in $reqid_db) {
write-host "Line: "$line
$reqid_db2 = $reqid_db2 + $line
}
certutil.exe -view -out "Request.requestid,Request.requestid" -restrict "CertificateTemplate=$certtmpl,Disposition=20,NotBefore>now-$dbscanperiod" csv > $sendcertpath\sendcert_scope.csv
$collection = @(Import-CSV $sendcertpath\sendcert_scope.csv)
write-host Issued certs during period: $collection.count
if ($collection.count -gt 0) {
foreach($CADBentry in $collection)
{
$reqid = $CADBentry."request id"
if ($reqid_db2 -notcontains $reqid) {
write-host 'Preparing email for request: ' $reqid
$certview = certutil.exe -view -out "rawcertificate" -restrict "Request.requestid=$reqid"
$certemail = @()
$certattach = @()
foreach($line in $certview)
{
#write-host "Line: " $line
if ( $line -eq "-----BEGIN CERTIFICATE-----" ) { $certbegin="1" }
if ( $certbegin -eq "1") {
#write-host "next person in line pls"
$certemail = $certemail + $line.trim() + "`n" #+ "`r`n"
$certattach = $certattach + $line.trim() # + "`n" #+ "`r`n"
}
if ( $line -eq "-----END CERTIFICATE-----" ) { $certbegin="0" }
}
$cadb_requser= certutil.exe -view -out "Requester Name" -restrict "Request.requestid=$reqid" csv
$requser = $cadb_requser[1]
$requser = $requser.split("\")
$user = $requser[1]
$requser = $user.split("`"")
$user = $requser[0]
$aduser=""
try {
$aduser = get-aduser $user -Properties mail
#$aduser.mail
}
catch [Exception] {
write-host $_.Exception.Message
}
if ($aduser.mail.length -lt 1) {
write-host "no email address found"
} else {
$certattach > $sendcertpath\$reqid"."$certfileExt
$msg=new-object System.Net.Mail.MailMessage
$msg.From=$msgFrom
$msg.to.Add($aduser.mail)
$msg.Subject=$env:computername + ": SSL certificate " + $reqid
$msg.IsBodyHtml=$false
$mailbody = @()
$getmailbody = Get-Content mailbody.txt
foreach ($line in $getmailbody) {
$mailbody = $mailbody + $line + "`n"
}
$msg.Body=@"
$mailbody
$certemail
-
Ref $reqid_$env:computername
"@
$att = new-object Net.Mail.Attachment($sendcertpath + "\" + $reqid + "." + $certfileExt)
$msg.Attachments.Add($att)
$smtp=new-object System.Net.Mail.SmtpClient
$smtp.host=$smtphost
try {
$smtp.Send($msg)
$reqid >> $sendcertpath\reqid_do_not_remove.txt
}
catch {
write-host $_.Exception.Message
}
finally {
$smtp.dispose
$att.dispose()
}
}
}
}
}
the Windows Certification Authority has a built in feature (Windows Enterprise SKU) to send out emails to inform the PKI administrators if a new pending certificate request waiting for approval or if a new certificate has been issued. Just 2 examples.
The configuration must be done in the registry: See here for an example
http://social.technet.microsoft.com/wiki/contents/articles/2004.active-directory-certificate-services-smtp-exit-module-for-windows-server-2008-r2-example.aspx
Unfortunately you cannot configure it to send the issued certificate to the certificate requestor. For that I wrote a PowerShell script what is also working with the Windows Server 2008 R2 Standard Server.
Config file - sendcert_inc.ps1:
$sendcertpath=".\sendcert"
$msgFrom='noreply@frontoso.com'
$smtphost='127.0.0.1'
$certtmpl="1.3.6.1.4.1.311.21.8.5245527.10310595.8014498.11013764.15833798.137.13192380.4508386" #CorpWebServer
$certfileExt="txt" # fyi: extensions cer and der are blocked by Outlook
$mailbody="mailbody.txt"
$dbscanperiod="03:00" # 01:00 = 1 day, 1:15 = 1 day 15 hours; $dbscanperiod is the max time (now - $dbscanperiod) sendcert goes back in the certificate database, e.g. useful if you have already issued certs for years and you going to enable sendcert now
Mailbody.txt
Hello, attached is the requested certificate.
Please download the certificate and proceed with the SSL/TLS setup of your application.
For your convenience the certificate can be found as attachment and in the mail body.
Thank you,
----------------------------------------------------------------------------
Do not reply to this message. It was sent from an unmonitored email account.
sendcert.ps1
#
# Author: lutz.mueller-hipper@tribaldi.net
# Updates: lutz.mueller-hipper@insight.com
# Date: May 23, 2013 - v3.1
#
clear
import-module ActiveDirectory
# if not yet installed please install the ActiveDirectory PowerShell module
#dism /online /enable-feature /featurename:ActiveDirectory-PowerShell
if (-not (Test-Path .\sendcert_inc.ps1))
{
write-host "Error: sendcert_inc.ps1 configuration file not found." >>sendcert.log
exit;
} else {
. .\sendcert_inc.ps1
}
if (-not (Test-Path $sendcertpath)) { mkdir $sendcertpath >$null}
$Arr_SendCert = @()
write-host "=========================="
write-host Start Send certificate via email to certificate requestor
write-host "=========================="
write-host
#Disposition Description
#20 certificate was issued
#21 certificate is revoked
#30 certificate request failed
#31 certificate request is denied
$reqid_db = @()
$reqid_db = get-content $sendcertpath\reqid_do_not_remove.txt
$reqid_db2 = @()
foreach ( $line in $reqid_db) {
write-host "Line: "$line
$reqid_db2 = $reqid_db2 + $line
}
certutil.exe -view -out "Request.requestid,Request.requestid" -restrict "CertificateTemplate=$certtmpl,Disposition=20,NotBefore>now-$dbscanperiod" csv > $sendcertpath\sendcert_scope.csv
$collection = @(Import-CSV $sendcertpath\sendcert_scope.csv)
write-host Issued certs during period: $collection.count
if ($collection.count -gt 0) {
foreach($CADBentry in $collection)
{
$reqid = $CADBentry."request id"
if ($reqid_db2 -notcontains $reqid) {
write-host 'Preparing email for request: ' $reqid
$certview = certutil.exe -view -out "rawcertificate" -restrict "Request.requestid=$reqid"
$certemail = @()
$certattach = @()
foreach($line in $certview)
{
#write-host "Line: " $line
if ( $line -eq "-----BEGIN CERTIFICATE-----" ) { $certbegin="1" }
if ( $certbegin -eq "1") {
#write-host "next person in line pls"
$certemail = $certemail + $line.trim() + "`n" #+ "`r`n"
$certattach = $certattach + $line.trim() # + "`n" #+ "`r`n"
}
if ( $line -eq "-----END CERTIFICATE-----" ) { $certbegin="0" }
}
$cadb_requser= certutil.exe -view -out "Requester Name" -restrict "Request.requestid=$reqid" csv
$requser = $cadb_requser[1]
$requser = $requser.split("\")
$user = $requser[1]
$requser = $user.split("`"")
$user = $requser[0]
$aduser=""
try {
$aduser = get-aduser $user -Properties mail
#$aduser.mail
}
catch [Exception] {
write-host $_.Exception.Message
}
if ($aduser.mail.length -lt 1) {
write-host "no email address found"
} else {
$certattach > $sendcertpath\$reqid"."$certfileExt
$msg=new-object System.Net.Mail.MailMessage
$msg.From=$msgFrom
$msg.to.Add($aduser.mail)
$msg.Subject=$env:computername + ": SSL certificate " + $reqid
$msg.IsBodyHtml=$false
$mailbody = @()
$getmailbody = Get-Content mailbody.txt
foreach ($line in $getmailbody) {
$mailbody = $mailbody + $line + "`n"
}
$msg.Body=@"
$mailbody
$certemail
-
Ref $reqid_$env:computername
"@
$att = new-object Net.Mail.Attachment($sendcertpath + "\" + $reqid + "." + $certfileExt)
$msg.Attachments.Add($att)
$smtp=new-object System.Net.Mail.SmtpClient
$smtp.host=$smtphost
try {
$smtp.Send($msg)
$reqid >> $sendcertpath\reqid_do_not_remove.txt
}
catch {
write-host $_.Exception.Message
}
finally {
$smtp.dispose
$att.dispose()
}
}
}
}
}
Friday, March 29, 2013
Cannot request a certificate and Error 1722: The RPC server is unavailable
RPC errors can be ugly and are often not that easy to identify. In the last months I had two Windows PKI Installations where I ran into the error 1722 RPC server not available. In both cases the Windows CA was up and running but I could not enroll or autoenroll certificates. So I check the firewall rules, the CA server time and date and I used certutil.exe -ping CAhostname to verify RPC network communication.
I ran certutil -ping one time with the netbios name of the CA and all worked. That's why no one had an issued with the machine before for file transfer or a ping with the netbios name.
C:\system\>certutil -ping win5011
Connecting to win5011 ...
Server "AAA Frontoso R3" ICertRequest2 interface is alive
CertUtil: -ping command completed successfully.
But the certutil -ping for the full qualified hostname failed.
C:\system\adhc>certutil -ping win5011.frontoso.com
Connecting to win5011.frontoso.com ...
Server could not be reached: The RPC server is unavailable. 0x800706ba (WIN32: 1722)
CertUtil: -ping command FAILED: 0x800706ba (WIN32: 1722)
CertUtil: The RPC server is unavailable.
So it turned out that in both cases the client used a non-MS DNS server for the Active Directory environment and the FQDN name of the CA server was incorrectly configured there. After adjusting the IP address in DNS certutil -ping with the FQDN name worked and the certificate enrollment as well.
I ran certutil -ping one time with the netbios name of the CA and all worked. That's why no one had an issued with the machine before for file transfer or a ping with the netbios name.
C:\system\>certutil -ping win5011
Connecting to win5011 ...
Server "AAA Frontoso R3" ICertRequest2 interface is alive
CertUtil: -ping command completed successfully.
But the certutil -ping for the full qualified hostname failed.
C:\system\adhc>certutil -ping win5011.frontoso.com
Connecting to win5011.frontoso.com ...
Server could not be reached: The RPC server is unavailable. 0x800706ba (WIN32: 1722)
CertUtil: -ping command FAILED: 0x800706ba (WIN32: 1722)
CertUtil: The RPC server is unavailable.
So it turned out that in both cases the client used a non-MS DNS server for the Active Directory environment and the FQDN name of the CA server was incorrectly configured there. After adjusting the IP address in DNS certutil -ping with the FQDN name worked and the certificate enrollment as well.
Ease Your Life when using Openssl s_client
I am really a big fan of openssl for certificate and network communication troubleshooting. And I am using it most of time from a Windows system.
I use the openssl s_client command very often to verify the network connectivity to a web or application server and to troubleshoot certificate errors in applications.
Openssl s_client gives out a lot of valuable information, but for inspecting the certificate you have first to transfer it into the correct file format. That should be easier to do. :-)
Example: openssl s_client -connect www.google.com:443
Loading 'screen' into random state - done
CONNECTED(00000128)
depth=1 C = US, O = Google Inc, CN = Google Internet Authority
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com
i:/C=US/O=Google Inc/CN=Google Internet Authority
1 s:/C=US/O=Google Inc/CN=Google Internet Authority
i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIDgDCCAumgAwIBAgIKO6d8eAAAAACBeTANBgkqhkiG9w0BAQUFADBGMQswCQYD
VQQGEwJVUzETMBEGA1UEChMKR29vZ2xlIEluYzEiMCAGA1UEAxMZR29vZ2xlIElu
dGVybmV0IEF1dGhvcml0eTAeFw0xMzAzMTMxMzUyNDJaFw0xMzA2MDcxOTQzMjda
MGgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1N
b3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMRcwFQYDVQQDEw53d3cu
Z29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAzhYmBbH1F/Es
0HQevxU1WnQ+08bGZS615oiYVxxl2D74Nf4WbQRuXs6iju+RLOFrNAKgOPtQ8DLw
zo/ln9yzzm1iXGQJa8lOScTMdTg/4UQAQjJ5F8fYZr8zAdQbur/BQ5YSiyVqLO0t
N3IeezSvYC9r5SwSMLmnEqXCIa5B8sECAwEAAaOCAVEwggFNMB0GA1UdJQQWMBQG
CCsGAQUFBwMBBggrBgEFBQcDAjAdBgNVHQ4EFgQUdfF5NV20rqEcyl3mVAxqB7bE
2JkwHwYDVR0jBBgwFoAUv8Aw6/VDET5nup6R+/xq2uNrEiQwWwYDVR0fBFQwUjBQ
oE6gTIZKaHR0cDovL3d3dy5nc3RhdGljLmNvbS9Hb29nbGVJbnRlcm5ldEF1dGhv
cml0eS9Hb29nbGVJbnRlcm5ldEF1dGhvcml0eS5jcmwwZgYIKwYBBQUHAQEEWjBY
MFYGCCsGAQUFBzAChkpodHRwOi8vd3d3LmdzdGF0aWMuY29tL0dvb2dsZUludGVy
bmV0QXV0aG9yaXR5L0dvb2dsZUludGVybmV0QXV0aG9yaXR5LmNydDAMBgNVHRMB
Af8EAjAAMBkGA1UdEQQSMBCCDnd3dy5nb29nbGUuY29tMA0GCSqGSIb3DQEBBQUA
A4GBAKD8fqndlHcfvIHSXo5R/ehNsRXkyinvxwG4r1oMuO60c1KRV0DB22Mvqjp5
vn4nnkYfiVoQv/LlsIBy48is9jKB5AYyPq5R3LSrn7iheYlGY1omSZkdmHDBLtcl
+TtjTtz444O+7dYZAM0GyUdf/3HUoebs949KIu2Cg5QS8INZ
-----END CERTIFICATE-----
subject=/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com
issuer=/C=US/O=Google Inc/CN=Google Internet Authority
---
No client certificate CA names sent
---
SSL handshake has read 2103 bytes and written 332 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-RC4-SHA
Server public key is 1024 bit
Secure Renegotiation IS supported
Compression: NONE
[cut]
Information about the validity (start,end), the server certificate thumbprint are not displayed. In the past I copied the lines from BEGIN CERTIFICATE to END CERTIFICATE into a text file using Notepad and I saved the file as cert1.cer. Then I could double-click the file in Windows Explorer and I had a nice interface to search through all attributes. Last week I figured out a more convenient way to do that. You can redirect the entire openssl s_client output into a cert1.cer file and the Windows Certificate Wizard is smart enough to read just the certificate from all the result data.
openssl s_client -connect www.google.com:443 > cert1.cer
Now you have a nice looking graphical interface to go through all the certificate information.
I use the openssl s_client command very often to verify the network connectivity to a web or application server and to troubleshoot certificate errors in applications.
Openssl s_client gives out a lot of valuable information, but for inspecting the certificate you have first to transfer it into the correct file format. That should be easier to do. :-)
Example: openssl s_client -connect www.google.com:443
Loading 'screen' into random state - done
CONNECTED(00000128)
depth=1 C = US, O = Google Inc, CN = Google Internet Authority
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com
i:/C=US/O=Google Inc/CN=Google Internet Authority
1 s:/C=US/O=Google Inc/CN=Google Internet Authority
i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIDgDCCAumgAwIBAgIKO6d8eAAAAACBeTANBgkqhkiG9w0BAQUFADBGMQswCQYD
VQQGEwJVUzETMBEGA1UEChMKR29vZ2xlIEluYzEiMCAGA1UEAxMZR29vZ2xlIElu
dGVybmV0IEF1dGhvcml0eTAeFw0xMzAzMTMxMzUyNDJaFw0xMzA2MDcxOTQzMjda
MGgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1N
b3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMRcwFQYDVQQDEw53d3cu
Z29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAzhYmBbH1F/Es
0HQevxU1WnQ+08bGZS615oiYVxxl2D74Nf4WbQRuXs6iju+RLOFrNAKgOPtQ8DLw
zo/ln9yzzm1iXGQJa8lOScTMdTg/4UQAQjJ5F8fYZr8zAdQbur/BQ5YSiyVqLO0t
N3IeezSvYC9r5SwSMLmnEqXCIa5B8sECAwEAAaOCAVEwggFNMB0GA1UdJQQWMBQG
CCsGAQUFBwMBBggrBgEFBQcDAjAdBgNVHQ4EFgQUdfF5NV20rqEcyl3mVAxqB7bE
2JkwHwYDVR0jBBgwFoAUv8Aw6/VDET5nup6R+/xq2uNrEiQwWwYDVR0fBFQwUjBQ
oE6gTIZKaHR0cDovL3d3dy5nc3RhdGljLmNvbS9Hb29nbGVJbnRlcm5ldEF1dGhv
cml0eS9Hb29nbGVJbnRlcm5ldEF1dGhvcml0eS5jcmwwZgYIKwYBBQUHAQEEWjBY
MFYGCCsGAQUFBzAChkpodHRwOi8vd3d3LmdzdGF0aWMuY29tL0dvb2dsZUludGVy
bmV0QXV0aG9yaXR5L0dvb2dsZUludGVybmV0QXV0aG9yaXR5LmNydDAMBgNVHRMB
Af8EAjAAMBkGA1UdEQQSMBCCDnd3dy5nb29nbGUuY29tMA0GCSqGSIb3DQEBBQUA
A4GBAKD8fqndlHcfvIHSXo5R/ehNsRXkyinvxwG4r1oMuO60c1KRV0DB22Mvqjp5
vn4nnkYfiVoQv/LlsIBy48is9jKB5AYyPq5R3LSrn7iheYlGY1omSZkdmHDBLtcl
+TtjTtz444O+7dYZAM0GyUdf/3HUoebs949KIu2Cg5QS8INZ
-----END CERTIFICATE-----
subject=/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com
issuer=/C=US/O=Google Inc/CN=Google Internet Authority
---
No client certificate CA names sent
---
SSL handshake has read 2103 bytes and written 332 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-RC4-SHA
Server public key is 1024 bit
Secure Renegotiation IS supported
Compression: NONE
[cut]
Information about the validity (start,end), the server certificate thumbprint are not displayed. In the past I copied the lines from BEGIN CERTIFICATE to END CERTIFICATE into a text file using Notepad and I saved the file as cert1.cer. Then I could double-click the file in Windows Explorer and I had a nice interface to search through all attributes. Last week I figured out a more convenient way to do that. You can redirect the entire openssl s_client output into a cert1.cer file and the Windows Certificate Wizard is smart enough to read just the certificate from all the result data.
openssl s_client -connect www.google.com:443 > cert1.cer
Now you have a nice looking graphical interface to go through all the certificate information.
Tuesday, December 4, 2012
Certificate Autoenrollment and RDS cause a certificate flood
All,
I love using machine certificates for RDP SSL as well. This week I came across an issue where I first thought autoenrollment is freaking out and generates on every reboot or gpupdate /force a new certificate.
After I found tons of articles why autoenrollment is not working at all but nothing about issuing to many certificates. I luckily found an article about the GPO settings for RDP.
http://social.technet.microsoft.com/Forums/en-US/winserverTS/thread/382774a9-5b2c-4d54-9abb-03357adccc08
RDP GPO settings http://technet.microsoft.com/en-us/library/cc771869(WS.10).aspx
So it seems that this "known" issue is not yet fixed. Or perhaps it is and I just do not know the KB article number.
Solution in short: Keep "Template Display Name" and "Template Name" with the exact same spelling and no spaces. See below.
I love using machine certificates for RDP SSL as well. This week I came across an issue where I first thought autoenrollment is freaking out and generates on every reboot or gpupdate /force a new certificate.
After I found tons of articles why autoenrollment is not working at all but nothing about issuing to many certificates. I luckily found an article about the GPO settings for RDP.
http://social.technet.microsoft.com/Forums/en-US/winserverTS/thread/382774a9-5b2c-4d54-9abb-03357adccc08
RDP GPO settings http://technet.microsoft.com/en-us/library/cc771869(WS.10).aspx
So it seems that this "known" issue is not yet fixed. Or perhaps it is and I just do not know the KB article number.
Solution in short: Keep "Template Display Name" and "Template Name" with the exact same spelling and no spaces. See below.
Thursday, October 25, 2012
New study about Validating SSL Certiļ¬cates in Non-Browser Software
Scientist from The University of Texas and the Stanford University have published a study about SSL encryption in several products and services.
Even applications using data encryption they do not perform an proper identity verification of the sender or receiver. I have seen this before for online backup services, password sync tools etc.
So that is not a new thing, but it is amazing that we still have to deal with that.
Read the article http://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf
Tuesday, August 21, 2012
certlm.msc - Short cut to open the certificate store for the local machine
Sometimes even small a thing can be a time saver.
So in Windows 2012 you can just type certlm.msc to start the certificates MMC with the local machine store.
So in Windows 2012 you can just type certlm.msc to start the certificates MMC with the local machine store.
Monday, July 16, 2012
In-place migration Windows 2008 R2 to Windows 2012 Certification Authority
I migrated a couple of machine from Windows 2008 R2 to Windows 2012. Greatly it was working well also for remote machines and even a remote access server came back after a while and I could dial in again (Note: I had a SSH connection to the host for backup to get in - I am not that brave.)
Last migration I did was a CA and after migrating I could request certificates and I saw new CRLs. So all is good. Almost, I could not see the MMC for certificate templates and the certification authority.
I had to manually install them first.
or take the shortcut:
c:\>dism /online /enable-feature /featurename:CertificateServicesManagementTools
Small thing but good to know.
Monday, November 14, 2011
Do I need a OCSP responder?
OCSP - Online Certificate Status Protocol
I was thinking about the question, why and when should I add OCSP for a PKI. And I see a lot of points why smaller organizations might not have a need for OCSP and large companies not necessarily.
- with Windows 2008 R2 OCSP uses the CRL as data set. So you must issued fresh CRLs more often.
- if you do not revoked certificates or have a alternative method to block access to your service, e.g. disable the user account in AD, then OCSP is only overhead. Review your revocation policy, if you dont have one - create one!
- Might not all of your clients "speak" OCSP (e.g. Windows 2000 and Windows XP)
- Check network connectivity from all your potential clients to the OCSP server, your clients talk on each certificate check back to OCSP. This can cause latency issues for your applications
- For e.g. Cisco concentrators you do not need to publish the OCSP path to all certificates, you can configure the OCSP path on the concentrator.
- Most clients cache the CRL locally, so if the CRL distribution point is not available for a short time, lets say 4 hours when your CRL validity is 2 weeks, still most of your systems would work without any issue. If you rely only on OCSP then make it high available.
- think also about additional license cost, operational costs and support
OCSP is a great improvement in environments with a high number of revokes, what means you have larger CRLs (in size). Unfortunately it is not easy to say when OCSP makes sense and when not, it highly depends how applications check for revocation status.
And OCSP is not a simple replacement for CRLs, it gives you more capabilities to manage certificate revocation. So it is more a logical extension of a PKI.
[Update] Google disables CRL and OCSP checks in the next Chrome version http://www.imperialviolet.org/2012/02/05/crlsets.html
---------------------------
Note 1: You can use 3rd party OCSP responder or clients as well to overcome Windows OCSP limitations.
Note 2: On Windows 2008 R2 Server Enterprise Edition is needed for each OCSP server installation.
I was thinking about the question, why and when should I add OCSP for a PKI. And I see a lot of points why smaller organizations might not have a need for OCSP and large companies not necessarily.
- with Windows 2008 R2 OCSP uses the CRL as data set. So you must issued fresh CRLs more often.
- if you do not revoked certificates or have a alternative method to block access to your service, e.g. disable the user account in AD, then OCSP is only overhead. Review your revocation policy, if you dont have one - create one!
- Might not all of your clients "speak" OCSP (e.g. Windows 2000 and Windows XP)
- Check network connectivity from all your potential clients to the OCSP server, your clients talk on each certificate check back to OCSP. This can cause latency issues for your applications
- For e.g. Cisco concentrators you do not need to publish the OCSP path to all certificates, you can configure the OCSP path on the concentrator.
- Most clients cache the CRL locally, so if the CRL distribution point is not available for a short time, lets say 4 hours when your CRL validity is 2 weeks, still most of your systems would work without any issue. If you rely only on OCSP then make it high available.
- think also about additional license cost, operational costs and support
OCSP is a great improvement in environments with a high number of revokes, what means you have larger CRLs (in size). Unfortunately it is not easy to say when OCSP makes sense and when not, it highly depends how applications check for revocation status.
And OCSP is not a simple replacement for CRLs, it gives you more capabilities to manage certificate revocation. So it is more a logical extension of a PKI.
[Update] Google disables CRL and OCSP checks in the next Chrome version http://www.imperialviolet.org/2012/02/05/crlsets.html
---------------------------
Note 1: You can use 3rd party OCSP responder or clients as well to overcome Windows OCSP limitations.
Note 2: On Windows 2008 R2 Server Enterprise Edition is needed for each OCSP server installation.
Subscribe to:
Posts (Atom)

















