Changes between Version 3 and Version 4 of ldapiam2018
- Timestamp:
- Sep 4, 2018, 6:55:18 AM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ldapiam2018
v3 v4 11 11 sudo dpkg-reconfigure slapd 12 12 }}} 13 Answer the prompts appropriately, using t'''***No''' (we want an initial database and configuration) 13 Answer the prompts appropriately, using the information below as a starting point: 14 * Omit OpenLDAP server configuration? '''No''' (we want an initial database and configuration) 14 15 * DNS domain name: '''YOUR-DOMAIN''' (use the server's domain name, minus the hostname. This will be used to create the base entry for the information tree) 15 16 * Organization name: '''Your Institute''' (This will simply be added to the base entry as the name of your institute) … … 21 22 === Create the Certificate Templates === 22 23 To encrypt our connections, we'll need to configure a certificate authority and use it to sign the keys for the LDAP server(s) in our infrastructure. So for our single server setup, we will need two sets of key/certificate pairs: one for the certificate authority itself and one that is associated with the LDAP service. 24 23 25 To create the certificates needed to represent these entities, we'll create some template files. These will contain the information that the certtool utility needs in order to create certificates with the appropriate properties. 26 24 27 Start by making a directory to store the template files: 25 28 {{{ … … 37 40 }}} 38 41 Save and close the file. 42 39 43 Next, we can create a template for our LDAP server certificate called ldap_server.conf. Create and open the file in your text editor with sudo privileges: 40 44 {{{ … … 42 46 }}} 43 47 Here, we'll provide a few different pieces of information. We'll provide the name of our organization and set the tls_www_server, encryption_key, and signing_key options so that our cert has the basic functionality it needs. 48 44 49 The cn in this template must match the FQDN of the LDAP server. If this value does not match, the client will reject the server's certificate. We will also set the expiration date for the certificate. We'll create a 10 year certificate to avoid having to manage frequent renewals: `ldapserver.conf` 45 50 {{{ … … 52 57 }}} 53 58 Save and close the file when you're finished. 59 54 60 === Create CA Key and Certificate === 55 61 Now that we have our templates, we can create our two key/certificate pairs. We need to create the certificate authority's set first. 62 56 63 Use the certtool utility to generate a private key. The `/etc/ssl/private` directory is protected from non-root users and is the appropriate location to place the private keys we will be generating. We can generate a private key and write it to a file called ca_server.key within this directory by typing: 57 64 {{{ … … 63 70 }}} 64 71 We now have the private key and certificate pair for our certificate authority. We can use this to sign the key that will be used to actually encrypt the LDAP session. 72 65 73 === Create LDAP Service Key and Certificate === 66 74 Next, we need to generate a private key for our LDAP server. We will again put the generated key in the `/etc/ssl/private` directory for security purposes and will call the file ldap_server.key for clarity. 75 67 76 We can generate the appropriate key by typing: 68 77 {{{ … … 70 79 }}} 71 80 Once we have the private key for the LDAP server, we have everything we need to generate a certificate for the server. We will need to pull in almost all of the components we've created thus far (the CA certificate and key, the LDAP server key, and the LDAP server template). 81 72 82 We will put the certificate in the `/etc/ssl/certs` directory and name it `ldap_server.pem`. The command we need is: 73 83 {{{ 74 84 sudo certtool -c --load-privkey /etc/ssl/private/ldap_server.key --load-ca-certificate /etc/ssl/certs/ca_server.pem --load-ca-privkey /etc/ssl/private/ca_server.key --template /etc/ssl/templates/ldap_server.conf --outfile /etc/ssl/certs/ldap_server.pem 75 85 }}} 86 76 87 === Give OpenLDAP Access to the LDAP Server Key === 77 88 We now have all of the certificates and keys we need. However, currently, our OpenLDAP process will be unable to access its own key. 89 78 90 A group called ssl-cert already exists as the group-owner of the `/etc/ssl/private` directory. We can add the user our OpenLDAP process runs under (openldap) to this group: 79 91 {{{ … … 89 101 }}} 90 102 Our OpenSSL process can now access the key file properly. Configure OpenLDAP to Use the Certificate and Keys 103 91 104 We have our files and have configured access to the components correctly. Now, we need to modify our OpenLDAP configuration to use the files we've made. We will do this by creating an LDIF file with our configuration changes and loading it into our LDAP instance. 105 92 106 Move to your home directory and open a file called `addcerts.ldif`. We will put our configuration changes in this file: 93 107 {{{ … … 96 110 }}} 97 111 To make configuration changes, we need to target the cn=config entry of the configuration DIT. We need to specify that we are wanting to modify the attributes of the entry. Afterwards we need to add the `olcTLSCACertificateFile`, `olcCertificateFile`, and `olcCertificateKeyFile` attributes and set them to the correct file locations. 112 98 113 The end result will look like this: 99 114 {{{ … … 118 133 }}} 119 134 If you see some error while importing, 135 120 136 Start your `slapd` in debug mode 121 137 {{{ … … 132 148 }}} 133 149 Your clients can now be configured to encrypt their connections to the server over the conventional 'ldap://ldap.YOUR-DOMAIN:389' port by using STARTTLS. 150 134 151 == Setting up the Client Machines == 135 In order to connect to the LDAP server and initiate a STARTTLS upgrade, the clients must have access to the certificate authority certificate and must request the upgrade. 136 On the OpenLDAP Server 152 In order to connect to the LDAP server and initiate a STARTTLS upgrade, the clients must have access to the certificate authority certificate and must request the upgrade.On the OpenLDAP Server 153 137 154 If you are interacting with the OpenLDAP server from the server itself, you can set up the client utilities by copying the CA certificate and adjusting the client configuration file. 155 138 156 First, copy the CA certificate from the `/etc/ssl/certs` directory to a file within the `/etc/ldap` directory. We will call this file ca_certs.pem. This file can be used to store all of the CA certificates that clients on this machine may wish to access. For our purposes, this will only contain a single certificate: 139 157 {{{ … … 163 181 === Load eduPerson Schema === 164 182 Get the schema downloaded from [https://ws.learn.ac.lk/raw-attachment/wiki/ldapiam2018/eduperson-201602.ldif eduperson-201602.ldif] 183 165 184 Or the latest from `https://spaces.at.internet2.edu/display/macedir/LDIFs` 185 166 186 Load it using: 167 187 {{{ … … 169 189 }}} 170 190 Also Lets load The SChema for Academia, SCHAC. 171 Get the schema downloaded from [https://ws.learn.ac.lk/raw-attachment/wiki/ldapiam2018/SCHAC.ldif SCHAC.ldif][SCHAC.ldif](./schac-20150413.ldif) 191 192 Get the schema downloaded from [https://ws.learn.ac.lk/raw-attachment/wiki/ldapiam2018/SCHAC.ldif SCHAC.ldif] 193 172 194 Or the latest from `https://wiki.refeds.org/display/STAN/SCHAC+Releases` 195 173 196 Load it using: 174 197 {{{