{"id":406297,"date":"2024-06-29T18:51:01","date_gmt":"2024-06-29T18:51:01","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=406297"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=406297","title":{"rendered":"<span>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a AD \u0438\u0437 PHP \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 LDAPS<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u043f\u043e\u0441\u0442 <a href=\"http:\/\/habrahabr.ru\/post\/160681\/\" rel=\"nofollow noopener noreferrer\">\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f AD \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/a>, \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b, \u0447\u0442\u043e \u043e\u043a\u043e\u043b\u043e \u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434 \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u044b\u043b\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435 \u0443\u0434\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 LDAP, \u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 LDAPS. <a name=\"habracut\"><\/a>\u0412\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e \u0441\u0432\u043e\u0438 \u0437\u0430\u043f\u0438\u0441\u0438, \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f.<\/p>\n<p>  \u0412\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u0440\u043e\u0434\u0435\u043b\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0432 RHEL 5.5 \u0438 Windows Server 2003 R2 EE.<\/p>\n<h5>\u0421\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b<\/h5>\n<p>  \u041f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u043a\u0435\u0442 OpenSSL  <\/p>\n<pre><code class=\"bash\">rpm -ivh openssl-0.9.8e-12.el5_4.6.i686.rpm rpm -ivh openssl-perl-0.9.8e-12.el5_4.6.i386.rpm<\/code><\/pre>\n<p>  \u0424\u0430\u0439\u043b \/etc\/pki\/tls\/openssl.cnf  <\/p>\n<pre><code class=\"plaintext\">dir = \/root\/sslCA default_days = 3650 countryName_default = UA stateOrProvinceName_default = Lugansk localityName_default = Lugansk 0.organizationName_default = CompanyName organizationalUnitName_default  = IT ... # \u0432 \u043a\u043e\u043d\u0446\u0435 \u0444\u0430\u0439\u043b\u0430 [ sign_ias_csr ] subjectKeyIdentifier = hash authorityKeyIdentifier = keyid,issuer:always keyUsage = digitalSignature, keyEncipherment extendedKeyUsage = clientAuth,serverAuth <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">cd \/root\/ mkdir sslCA chmod 700 sslCA cd \/root\/sslCA mkdir certs private newcerts echo 1000 > serial touch index.txt openssl req -new -x509 -days 3650 -extensions v3_ca -keyout private\/cakey.pem -out cacert.pem -config \/etc\/pki\/tls\/openssl.cnf <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0421\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u0434\u043e\u043c\u0435\u043d\u0430<\/h5>\n<p>  \u0424\u0430\u0439\u043b \/root\/sslCA\/gencert.sh  <\/p>\n<pre><code class=\"bash\">#!\/bin\/sh NAME=$1 BITS=1024 CONFIG=\/etc\/pki\/tls\/openssl.cnf  # Generating the Certificate Request  # Create server key echo \"\"; echo \"Creating server key\"; echo \"\" openssl genrsa -des3 -out server${NAME}.key.pass -passout pass:1234 ${BITS} || exit  # Remove passphrase echo \"\"; echo \"Removing passphrase\"; echo \"\" openssl rsa -in server${NAME}.key.pass -out server${NAME}.key -passin pass:1234 || exit  # Generate certificate request echo \"\"; echo \"Generating certificate request\"; echo \"\" openssl req -config ${CONFIG} -new -days 3650 -key server${NAME}.key -out csr${NAME}.pem || exit  # Signing the Certificate echo \"\"; echo \"Signing the Certificate\"; echo \"\" openssl ca -config ${CONFIG} -days 3650 -extensions sign_ias_csr -out new${NAME}.pem -in csr${NAME}.pem || exit  # Generate a Public\/Private key file cp server${NAME}.key cert${NAME}.pem openssl x509 -in new${NAME}.pem >> cert${NAME}.pem || exit  # Generate the PKCS12 file echo \"\"; echo \"Generating PKCS12\"; echo \"\" openssl pkcs12 -name \"Test Cert\" -export -in cert${NAME}.pem -out cert${NAME}.p12 || exit <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">chmod +x \/root\/sslCA\/gencert.sh \/root\/sslCA\/gencert.sh 01 <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 **Common Name (eg, your name or your server&#8217;s hostname) []:** \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 FQDN DC \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442.  <\/p>\n<pre><code class=\"bash\">cp \/root\/sslCA\/cacert.pem \/etc\/pki\/tls\/certs\/ c_rehash rpm -ivh openldap-clients-2.3.43-12.el5.i386.rpm <\/code><\/pre>\n<p>  PHP \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 ldap<br \/>  \u0424\u0430\u0439\u043b \/etc\/openldap\/ldap.conf  <\/p>\n<pre><code class=\"plaintext\"># Instruct client to NOT request a server's cert. TLS_REQCERT never  # Define location of CA Cert TLS_CACERT \/etc\/pki\/tls\/certs\/cacert.pem TLS_CACERTDIR \/etc\/pki\/tls\/certs <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">cp \/etc\/openldap\/ldap.conf \/var\/www\/.ldaprc <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043d\u0430 DC<\/h5>\n<p>  1. \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0444\u0430\u0439\u043b\u044b<br \/>   * cert.p12 \u2014 The certificate<br \/>   * cacert.pem \u2014 The Root Certificate<\/p>\n<p>  2 .Start, Run, MMC, File, Add\/Remove Snap-in, Add, Certificates, Computer Account, Local Computer, My User Account, Next, Finish, Close, Ok<\/p>\n<p>  3. \u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c Certificates<\/p>\n<p>  4. \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c cacert.pem \u0432 Trusted Root Certificates Authorities (\u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043d\u0430 Trusted Root Certificates Authorities, All Tasks, Import, Next, Browse, All files, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0430\u0448 cacert.pem &#8230;)<\/p>\n<p>  5. \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c cert.p12 \u0432 Personal (\u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043d\u0430 Personal, All Tasks, Import, Next, Browse, All files, \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u0430\u0448 cert.p12, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0432\u0432\u043e\u0434\u0438\u043c \u043f\u0430\u0440\u043e\u043b\u044c &#8230;)<\/p>\n<p>  6. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430 \u043d\u0430 DC<br \/>   * \u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0438 Personal \u0438 Certificates<br \/>   * \u0414\u0432\u043e\u0439\u043d\u043e\u0439 \u0449\u043a\u043b\u0447\u043e\u043a \u043f\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0440\u0443<br \/>   * \u0423\u0431\u0435\u0436\u0434\u0430\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0430 \u00abYou have a private key that corresponds to this certificate\u00bb<\/p>\n<h5>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0437\u044f\u0437\u0438<\/h5>\n<p>  \u0424\u0430\u0439\u043b \/var\/www\/html\/test.php  <\/p>\n<pre><code class=\"php\">&lt;?php $ldapuser = \"administrator@testlab.local\"; $ldappass = \"superpass\"; $ldapserver = \"192.168.0.1\";  $ad = ldap_connect(\"ldaps:\/\/\".$ldapserver) or die(\"Cant connect to LDAP Server\"); ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3); $adbind = ldap_bind($ad, $ldapuser, $ldappass); if ($adbind) {     echo \"LDAP bind successful...\"; } else {     echo \"LDAP bind failed...\"; } ?> <\/code><\/pre>\n<p>  <a href=\"http:\/\/www.digitalissues.co.uk\/html\/os\/ms\/ldaps.html\" rel=\"nofollow noopener noreferrer\">www.digitalissues.co.uk\/html\/os\/ms\/ldaps.html<\/a><\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/724008\/\"> https:\/\/habr.com\/ru\/articles\/724008\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u043f\u043e\u0441\u0442 <a href=\"http:\/\/habrahabr.ru\/post\/160681\/\" rel=\"nofollow noopener noreferrer\">\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f AD \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/a>, \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b, \u0447\u0442\u043e \u043e\u043a\u043e\u043b\u043e \u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434 \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u044b\u043b\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435 \u0443\u0434\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 LDAP, \u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 LDAPS. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-406297","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/406297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=406297"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/406297\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=406297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=406297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=406297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}