Exchange 2013/2016: Wizard for certificates

Many of the emails I receive are always about certificates. I have therefore created a small wizard using PowerShell that takes some of the work out of dealing with certificates. It automatically searches for the relevant DNS names, requests the certificate from a Windows CA and installs it on all Exchange 2013 servers. However, it doesn't work without a bit of manual work:

Assistant

Prerequisites

The ActiveDirectory module for the PowerShell must be installed on the Exchange Server on which ExchangeCertificateAssistant is executed; the module can be installed in the Server Manager:

image

In order for the wizard to be able to request certificates, there must be a certificate template in addition to a certification authority. I have described how to install and configure a certification authority here:

If there is already an installed and configured certification authority, only a new template needs to be created. To do this, open the certificate template console in the MMC of the certification authority:

image

The "Web server" template must be duplicated

image

Define and remember the template display name in the new window under the General tab (queried by ExchangeCerttificateAssistant)

image

On the Request management tab, the checkboxes "Include symmetric algorithms approved by the requestor" and "Allow export of private keys" must be checked

image

On the Security tab, the "Exchange Trusted Subsystem" group is added with the rights "Read" and "Register"

image

You can now confirm with "OK" and close the certificate template console. The new template then only needs to be published

image

image

Once the template has been created and published, the wizard can be started from the Exchange Management Shell

Note: ExchangeCertificateAssistant requires Server 2012 R2, PowerShell 4, Exchange 2013 and the ActiveDirectory module for the Powershell. The Exchange server(s) must already be fully configured, for the configuration the Exchange Configurator be used.

Start ExchangeCertificateAssistant

.\ExchangeCertificateAssistant.ps1

image

The wizard asks for the template name; the template display name just assigned must be entered here

image

The rest should be self-explanatory. Before the certificate is issued, it is possible to add further DNS names that have not been configured in Exchange:

image

The certificate is then issued and bound to the Exchange services, and it is also saved under c:\Certificate on the Exchange server that executed the wizard. The password can be selected, so the certificate can be transferred to load balancers or firewalls.

image

Download:

 

Small update: The wizard also works with Exchange 2016.

21 thoughts on “Exchange 2013/2016: Assistent für Zertifikate”

  1. Hallo Frank,

    nochmals vielen Dank für Deine genialen Skripte und Artikel. Ich und viele andere wären ohne Dich nicht halb so weit bei der Administration unserer Exchange Server.

    Ich hätte mal eine Frage zum Zertifikats-Assistenten für Lets Encrypt: Ist es aus Deiner Sicht denkbar, DANE (DNS-based Authentication of Named Entities) mit Lets Encrypt umzusetzen?

    Liebe Grüße
    Michael

    Reply
  2. Hallo
    Ich komme nicht weiter, da ich die Fehlermeldung nicht beheben kann, und nicht verstehe was sie mir sagen will.

    Das script läuft bis 00:17:17 auf die unten stehende Fehlermeldung.

    11.03.2019 00:17:14;IIS;Info;Changing Let’s Encrypt IIS directory to http;
    11.03.2019 00:17:15;IIS;Info;Successfully changed Let’s Encrypt IIS directory to http;
    11.03.2019 00:17:15;IIS;Info;Checking Let’s Encrypt IIS directory to accept validation by http request;
    11.03.2019 00:17:15;IIS;Info;.well-known directory accepts http;
    11.03.2019 00:17:15;LE Challange;Info;Try to submit challenge;
    11.03.2019 00:17:16;LE Challange;Info;Submitted challenge for Alias Cert110320190017-1;
    11.03.2019 00:17:16;LE Challange;Info;Try to submit challenge;
    11.03.2019 00:17:17;LE Challange;Info;Updated Identifier for Alias Cert110320190017-1;
    11.03.2019 00:17:17;Certificate;Info;Try to create the certificate;
    11.03.2019 00:17:17;Certificate;Info;Using mail.gehlhaar.de as certificates CN;
    11.03.2019 00:17:17;Certificate;Error;Failed to create the certificate SAN110320190017; Unable to find an Identifier for the given reference

    Kann mir jemadn weiterhelfen warum er den Identifier nicht finden kann, bzw welchen Identifier er sucht.

    Danke

    Reply
  3. Heute geht nichts mehr. Habe den Server neu gestartet und jetzt sagt er beim Zertifikat Datum ungültig!

    Was nun???

    Reply
  4. Hi Frank, danke für dein bombastisches Skript. Hab auch noch ein Problem mit dem Renew. Task wird angelegt und der läuft auch soweit aber das Zertifikat wird leider nicht ausgetauscht. Hab das mal manuell gestartet und er macht soweit alles ganz brav. Die EX Shell wird geladen dann sehe ich noch „Exchange Server 2013/2016 wurde erkannt“ und dann geht er aus der Shell wieder raus. Bei den Zertifikaten wird leider nichts geändert, ein Fehler kommt auch nicht.

    Hättest du einen Tipp?
    Danke dir und VG
    Stefano

    Reply
  5. Hallo Frank,
    tolles Script – die initiale Ausstellung des Zertifikates funktioniert korrekt, nicht allerdings das Anlegen des geplanten Tasks für das Auto-Renewal. Bevor der Bildschirm gelöscht wird und „Alle Informationen sind vorhanden, soll das Zertifikat konfiguriert werden?“ erscheint sieht man auch kurz einen Fehler in rot, aber es geht zu schnell, als dass man erkennen könnte, was es ist.

    Hast Du einen Hinweis, wie man den Task manuell einrichten kann?

    Danke & Gruß
    Jan

    Reply
  6. Hallo Frank
    Ich bin der dritte im Bunde.
    wie kann ich die Bindung per Shell wieder herstellen?
    Exchange 2013
    Danke

    Reply
  7. Hallo,

    wie kann ich die Bindung per Shell wieder herstellen? Habe genau das gleiche Problem. wie Volker.

    Es geht bei mir um Exchange 2013
    Danke!

    Reply
  8. Hi Franky, bei uns ist es auch passiert – gleicher Fehler wie oben !! Nun haben wir ein echtes Problem …kommen nicht mal mehr auf ECP, das Standard Zertifikat ist weg und auch sonst gibt keine Zertifikate und Bindungen mehr auf unserem Exchange :-(

    Reply
    • Hi Volker,
      es werden keine Zertifikate gelöscht. Per Shell lassen sich die Bindungen wiederherstellen. Welche Exchange Version wird eingesetzt?
      Gruß, Frank

      Reply
  9. Hallo Frank,

    ich erhaltefolgende Fehlermeldung, kannst Du helfen?

    Get-Certificate : Falscher Parameter. 0x80070057 (WIN32: 87 ERROR_INVALID_PARAMETER)
    In D:\zertifikate\ExchangeCertificateAssistant.ps1:178 Zeichen:9
    + $cert = Get-Certificate -Template $template -DnsName $dnsnames -CertStoreLocatio …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Get-Certificate], Exception
    + FullyQualifiedErrorId : System.Exception,Microsoft.CertificateServices.Commands.GetCertificateCommand

    Export-PfxCertificate : Es wird kein Zertifikat exportiert, da die Eingabe leer ist.
    In D:\zertifikate\ExchangeCertificateAssistant.ps1:191 Zeichen:69
    + $export = Get-ChildItem -Path „cert:\localMachine\my\$thumbprint“ | Export-PfxCe …
    + ~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Export-PfxCertificate], ArgumentException
    + FullyQualifiedErrorId : NullInput,Microsoft.CertificateServices.Commands.ExportPfxCertificate

    Reply
  10. Hey Franky,

    ist es nicht möglich den -Subjectname mit einzubinden?

    $cert = Get-Certificate -Template $template -DnsName $dnsnames -SubjectName tester -CertStoreLocation cert:\LocalMachine\My -Url ldap:

    Erzeugt den Fehler, dass ein fehlerhaftes x500 Attribut vorhanden ist…
    Encode: The string contains an invalid X500 name attribute key, oid, …

    Hast Du eine Ahnung woran das liegen kann?
    Im Grunde ist es ja nur ein String, nichts spezielles

    Reply
  11. Hallo,

    bekomme folgenden fehler:

    Importiere und Aktiviere Zertifikat auf Server EXCHANGE
    Ein spezieller RPC-Fehler ist auf Server EXCHANGE aufgetreten: Das Zertifikat mit dem Fingerabdruck
    ’94D53F59AE899A9D3C0BC5B1AB1384CE5549C1DB‘ wurde gefunden, ist jedoch für die Verwendung mit Exchange Server nicht
    gültig (Begründung: SigningNotSupported).
    + CategoryInfo : NotSpecified: (:) [Enable-ExchangeCertificate], InvalidOperationException
    + FullyQualifiedErrorId : EA32EA0C,Microsoft.Exchange.Management.SystemConfigurationTasks.EnableExchangeCertificat
    e
    + PSComputerName : exchange.xxxx.local

    ———————————————————————
    Das Zertifikat wurde unter c:\Zertifikat\Exchange.pfx gesichert

    hast Du dazu ne Idee ?

    Reply
  12. hi frank,

    ich erhlalte folgende fehlermeldungen…

    Wurde die Zertifikatsvorlage erstellt? (j/n): j
    Bitte Name der Zertifikatsvorlage angeben: ExchangeCertificateAssistant
    Vorlage gefunden
    Bitte Passwort für die PFX-Datei eingeben: *********

    Lese DNS-Namen aus…
    WARNUNG: Das Cmdlet „Get-ClientAccessServer“ wird in einer künftigen Version von Exchange entfernt. Verwend
    stattdessen das Cmdlet „Get-ClientAccessService“. Wenn in Skripts das Cmdlet „Get-ClientAccessServer“ verwen
    aktualisieren Sie die Skripts, sodass sie das Cmdlet „Get-ClientAccessService“ verwenden. Weitere Informatio
    Sie unter „http://go.microsoft.com/fwlink/p/?LinkId=254711“.
    Folgende DNS-Namen werden auf dem Zertifikat eingetragen:

    esrv01.xxx.local

    ESRV01
    ESRV01.xxx.local
    autodiscover.xxx.local
    autodiscover.xxx.de

    Sollen dem Zertifikat weitere Namen hinzugefügt werden? (j/n): j
    Bitte DNS-Namen eingeben: mail.xxx.de
    Sollen dem Zertifikat weitere Namen hinzugefügt werden? (j/n): n

    Das Zertifikat wird mit folgenden Namen ausgestellt:

    esrv01.xxx.local

    ESRV01
    ESRV01.xxx.local
    autodiscover.xxx.local
    autodiscover.xxx.de
    mail.xxx.de

    Get-Certificate : Falscher Parameter. 0x80070057 (WIN32: 87 ERROR_INVALID_PARAMETER)
    In C:\Users\Administrator.xxx\Desktop\ExchangeCertificateAssistant.ps1:178 Zeichen:9
    + $cert = Get-Certificate -Template $template -DnsName $dnsnames -CertStoreLocatio …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Get-Certificate], Exception
    + FullyQualifiedErrorId : System.Exception,Microsoft.CertificateServices.Commands.GetCertificateCommand

    Export-PfxCertificate : Es wird kein Zertifikat exportiert, da die Eingabe leer ist.
    In C:\Users\Administrator.xxx\Desktop\ExchangeCertificateAssistant.ps1:191 Zeichen:69
    + $export = Get-ChildItem -Path „cert:\localMachine\my\$thumbprint“ | Export-PfxCe …
    + ~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Export-PfxCertificate], ArgumentException
    + FullyQualifiedErrorId : NullInput,Microsoft.CertificateServices.Commands.ExportPfxCertificate

    Importiere und Aktiviere Zertifikat auf Server ESRV01
    Zugriffsfehler für die importierte Zertifikatdatei für Server ESRV01. Ursache: Die Datei
    „\\ESRV01\c$\Zertifikat\Exchange.pfx“ konnte nicht gefunden werden.
    + CategoryInfo : InvalidOperation: (:) [Import-ExchangeCertificate], InvalidOperationException
    + FullyQualifiedErrorId : [Server=ESRV01,RequestId=9ea8ebbf-6a18-4c42-a691-6eefec1358e6,TimeStamp=10.11.
    :04] [FailureCategory=Cmdlet-InvalidOperationException] 3B8BDEDE,Microsoft.Exchange.Management.SystemConf
    Tasks.ImportExchangeCertificate
    + PSComputerName : esrv01.xxx.local

    Das Argument kann nicht an den Parameter „Thumbprint“ gebunden werden, da es sich um eine leere Zeichenfolge
    + CategoryInfo : InvalidData: (:) [Enable-ExchangeCertificate], ParameterBindingValidationExcep
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Enable-ExchangeCertifica
    + PSComputerName : esrv01.xxx.local

    Reply
  13. Hallo,
    Ist es richtig, dass in diesem Fall Zertifizierungsstelle und der Exchange-Server auf einem Rechner liegen müssen? Oder kann man die beiden Funktionen auch auf zwei Rechner verteilen?

    Reply
  14. Hallo nochmals,

    leider hatte ich keine andere Möglichkeit als den Webverwaltungsdient neu zu installieren, damit hat er sich das Standardzertifikat geholt und die Exchange Powershell ging wieder. Dann konnt ich ein Zertifikat erstellen und die Bindings der Defautl Web Site und der Back End Site darauf binden und somit hab ich den Exchange wieder sauber am laufen.
    Mich würde dennoch interressieren wie, warum sowas passieren kann und er, obwohl das Script mit nem Fehler abbricht, die Standard Exchange Zertifikate einfach unwiederruflich löscht. Ideen?

    Gruß JW

    Reply
  15. Hallo,

    ich habe das Script nun nach Anleitung ausgeführt. Beim erstellen des Scripts gibts dann eine Fehlermeldung:
    Get-Certificate : Falscher Parameter. 0x80070057 (WIN32: 87)
    In C:\Zertifikate_Exch\ExchangeCertificateAssistant.ps1:179 Zeichen:9
    + $cert = Get-Certificate -Template $template -DnsName $dnsnames -CertStoreLocatio …

    mit dem Ergebnis dass bisherige Zertifikate aus dem Zertifikasspeicher des Exchange gelöscht wurden.
    Warum? Wie komme ich an diese wieder dran?

    Danke und Gruß JW

    Reply
  16. Hallo Franky,
    vielen Dank für diese tolle Anleitung!
    Wenn ich das Skript ausführen will bekomme ich den Hinweis, dass dieses nicht digital zertifiziert sei.
    Hast Du mir dafür nen Tipp? Danke!

    Reply

Leave a Comment