<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://limyee.com/cfs-file/__key/system/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN"><title type="html">会员博客</title><subtitle type="html" /><id>https://limyee.com/b/members/atom</id><link rel="alternate" type="text/html" href="https://limyee.com/b/members" /><link rel="self" type="application/atom+xml" href="https://limyee.com/b/members/atom" /><generator uri="https://www.limyee.com" version="5.0.0.1268">Limyee CMS (Build: 5.0.0.1268)</generator><updated>2026-07-26T21:22:00Z</updated><entry><title>Enable LDAP over SSL (LDAPS) for Microsoft Active Directory servers</title><link rel="alternate" type="text/html" href="https://limyee.com/b/members/posts/enable-ldap-over-ssl-ldaps-for-microsoft-active-directory-servers" /><id>https://limyee.com/b/members/posts/enable-ldap-over-ssl-ldaps-for-microsoft-active-directory-servers</id><published>2026-07-26T13:22:00Z</published><updated>2026-07-26T13:22:00Z</updated><content type="html">&lt;p dir="auto"&gt;Microsoft active directory servers will default to offer LDAP connections over&amp;nbsp;&lt;em&gt;unencrypted&lt;/em&gt;&amp;nbsp;connections (boo!).&lt;/p&gt;
&lt;p dir="auto"&gt;The steps below will create a new self signed certificate appropriate for use with and thus enabling LDAPS for an AD server. Of course the &amp;quot;self-signed&amp;quot; portion of this guide can be swapped out with a real vendor purchased certificate if required.&lt;/p&gt;
&lt;p dir="auto"&gt;Steps have been tested successfully with Windows Server 2025. Requires a working &lt;a href="https://slproweb.com/products/Win32OpenSSL.html" rel="noopener" target="_blank"&gt;OpenSSL&lt;/a&gt; install (ideally Linux/OSX) and (obviously) a Windows Active Directory server.&lt;/p&gt;
&lt;h2 dir="auto"&gt;Create root certificate&lt;/h2&gt;
&lt;p dir="auto"&gt;Using OpenSSL, create new private key and root certificate. Answer country/state/org questions as suitable:&lt;/p&gt;
&lt;p dir="auto"&gt;&lt;pre class="ui-code" data-mode="bat"&gt;$ openssl genrsa -aes256 -out ca.key 4096
$ openssl req -new -x509 -days 3650 -key ca.key -out ca.crt&lt;/pre&gt;&lt;/p&gt;
&lt;p dir="auto"&gt;Hold onto the resulting&amp;nbsp;&lt;code&gt;ca.key&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code&gt;ca.crt&lt;/code&gt;.&lt;/p&gt;
&lt;h2 dir="auto"&gt;Import root certificate into trusted store of domain controller&lt;/h2&gt;
&lt;ul dir="auto"&gt;
&lt;li&gt;From the active directory server, open&amp;nbsp;&lt;code&gt;Manage computer certificates&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Add the generated&amp;nbsp;&lt;code&gt;ca.crt&lt;/code&gt;&amp;nbsp;to the certificate path&amp;nbsp;&lt;code&gt;Trusted Root Certification Authorities\Certificates&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Done.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 dir="auto"&gt;Create client certificate&lt;/h2&gt;
&lt;p dir="auto"&gt;We will now create a client certificate to be used for LDAPS, signed against our generated root certificate.&lt;/p&gt;
&lt;p dir="auto"&gt;From the active directory server:&lt;/p&gt;
&lt;ul dir="auto"&gt;
&lt;li&gt;
&lt;p dir="auto"&gt;Create a new&amp;nbsp;&lt;code&gt;request.inf&lt;/code&gt;&amp;nbsp;definition with the following contents - replacing&amp;nbsp;&lt;code&gt;ACTIVE_DIRECTORY_FQDN&lt;/code&gt;&amp;nbsp;with the qualified domain name of your active directory server:&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir="auto"&gt;&lt;pre class="ui-code" data-mode="text"&gt; [Version]
 Signature=&amp;quot;$Windows NT$&amp;quot;

 [NewRequest]
 Subject = &amp;quot;CN=ACTIVE_DIRECTORY_FQDN&amp;quot;
 KeySpec = 1
 KeyLength = 2048
 Exportable = TRUE
 MachineKeySet = TRUE
 SMIME = FALSE
 PrivateKeyArchive = FALSE
 UserProtected = FALSE
 UseExistingKeySet = FALSE
 ProviderName = &amp;quot;Microsoft RSA SChannel Cryptographic Provider&amp;quot;
 ProviderType = 12
 RequestType = PKCS10
 KeyUsage = 0xa0

 [EnhancedKeyUsageExtension]
 OID = 1.3.6.1.5.5.7.3.1 ; Server Authentication&lt;/pre&gt;&lt;/p&gt;
&lt;ul dir="auto"&gt;
&lt;li&gt;Run the following to create a client certificate request of&amp;nbsp;&lt;code&gt;client.csr&lt;/code&gt;&amp;nbsp;(note: it&amp;#39;s&amp;nbsp;&lt;em&gt;critical&lt;/em&gt;&amp;nbsp;this is run from the active directory server itself to ensure correct private key -&amp;gt; certificate association):&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;C:\&amp;gt; certreq -new request.inf client.csr&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Back to our OpenSSL system:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create&amp;nbsp;&lt;code&gt;v3ext.txt&lt;/code&gt;&amp;nbsp;containing the following:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;keyUsage=digitalSignature,keyEncipherment
extendedKeyUsage=serverAuth
subjectKeyIdentifier=hash&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a certificate&amp;nbsp;&lt;code&gt;client.crt&lt;/code&gt;&amp;nbsp;from certificate request&amp;nbsp;&lt;code&gt;client.csr&lt;/code&gt;&amp;nbsp;and root certificate (with private key):&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="bat"&gt;$ openssl x509 -req -days 3650 -in client.csr -CA ca.crt -CAkey ca.key -extfile v3ext.txt -set_serial 01 -out client.crt&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Verify generated certificate:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="bat"&gt;$ openssl x509 -in client.crt -text&lt;/pre&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Ensure the following&amp;nbsp;&lt;code&gt;X509v3 extensions&lt;/code&gt;&amp;nbsp;are&amp;nbsp;&lt;strong&gt;all present&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;X509v3 Key Usage: Digital Signature, Key Encipherment&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;X509v3 Extended Key Usage: TLS Web Server Authentication&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;X509v3 Subject Key Identifier&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 dir="auto"&gt;Accept and import certificate&lt;/h2&gt;
&lt;ul dir="auto"&gt;
&lt;li&gt;
&lt;p dir="auto"&gt;From the active directory server with&amp;nbsp;&lt;code&gt;client.crt&lt;/code&gt;&amp;nbsp;present, run the following:&lt;/p&gt;
&lt;div class="highlight highlight-source-batchfile"&gt;
&lt;pre&gt; C:\&lt;span class="pl-k"&gt;&amp;gt; certreq -accept client.crt&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir="auto"&gt;Open&amp;nbsp;&lt;code&gt;Manage computer certificates&lt;/code&gt;, the new certificate should now be present under&amp;nbsp;&lt;code&gt;Personal\Certificates&lt;/code&gt;. Ensure that:&lt;/p&gt;
&lt;ul dir="auto"&gt;
&lt;li&gt;Certificate has a private key association.&lt;/li&gt;
&lt;li&gt;The &amp;quot;Intended Purposes&amp;quot; is defined as &amp;quot;Server Authentication&amp;quot;.&lt;/li&gt;
&lt;li&gt;Certificate name is the FQDN of the active directory server.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 dir="auto"&gt;Reload active directory SSL certificate&lt;/h2&gt;
&lt;p dir="auto"&gt;Alternatively you can just reboot the server, but this method will instruct the active directory server to simply reload a suitable SSL certificate and if found, enable LDAPS:&lt;/p&gt;
&lt;ul dir="auto"&gt;
&lt;li&gt;
&lt;p dir="auto"&gt;Create&amp;nbsp;&lt;code&gt;ldap-renewservercert.txt&lt;/code&gt;&amp;nbsp;containing the following:&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;dn:
changetype: modify
add: renewServerCertificate
renewServerCertificate: 1&lt;/pre&gt;&lt;/p&gt;
&lt;ul dir="auto"&gt;
&lt;li&gt;
&lt;p dir="auto"&gt;&lt;/p&gt;
&lt;p dir="auto"&gt;Run the following command:&lt;/p&gt;
&lt;div class="highlight highlight-source-batchfile"&gt;
&lt;pre&gt; C:\&lt;span class="pl-k"&gt;&amp;gt; ldifde -i -f ldap-renewservercert.txt&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 dir="auto"&gt;Test LDAPS using&amp;nbsp;&lt;code&gt;ldp.exe&lt;/code&gt;&amp;nbsp;utility&lt;/h2&gt;
&lt;ul dir="auto"&gt;
&lt;li&gt;
&lt;p dir="auto"&gt;From&amp;nbsp;&lt;em&gt;another&lt;/em&gt;&amp;nbsp;domain controller, firstly install our generated root certificate&amp;nbsp;&lt;code&gt;ca.crt&lt;/code&gt;&amp;nbsp;to the certificate path&amp;nbsp;&lt;code&gt;Trusted Root Certification Authorities\Certificates&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir="auto"&gt;Open utility:&lt;/p&gt;
&lt;div class="highlight highlight-source-batchfile"&gt;
&lt;pre&gt; C:\&lt;span class="pl-k"&gt;&amp;gt; ldp.exe&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir="auto"&gt;From&amp;nbsp;&lt;code&gt;Connection&lt;/code&gt;, select&amp;nbsp;&lt;code&gt;Connect&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir="auto"&gt;Enter name of target domain controller.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir="auto"&gt;Enter&amp;nbsp;&lt;code&gt;636&lt;/code&gt;&amp;nbsp;as port number (this is the LDAPS port).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir="auto"&gt;Click&amp;nbsp;&lt;code&gt;OK&lt;/code&gt;&amp;nbsp;to confirm the connection works.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir="auto"&gt;You&amp;#39;re all done!&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Reference&lt;/h2&gt;
&lt;p&gt;Enable LDAP over SSL with a third-party certification authority: &lt;a href="https://support.microsoft.com/en-us/kb/321051" rel="noopener" target="_blank"&gt;https://support.microsoft.com/en-us/kb/321051&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="https://limyee.com/aggbug?PostID=9&amp;AppID=2&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</content><author><name>Bruce</name><uri>https://limyee.com/members/bruce</uri></author></entry></feed>