Since, everything is working as expected(hopefully!) we can enable SSL and finally force usage HTTPS terms of OCS communication. This will improve security and integrity of data. Let’s start with SSL certificate. In my previous guides there was a bit of confusion regarding SSL Certificate. I strongly advise using certificate that can be easily trusted by all clients (eg. Active Directory PKI generated, Let’s Encrypt and so on). I do not recommend using self signed certificates, unless you want to manually trust it when accessing OCS using web browser. Also, please remember that when deploying client certificate, one must provide valid CA/Issuer cert – not server cert(unless self signed is used). Also there are few tips that can help with certificate creation and trust:
- Multiple common names/dns names should be added as DNS fields, not common names. You can use fqdns as well as netbios names like, dns=ocsng, dns=ocsng.domain.com,dns=ocsng.anotherdomain.com etc.
- Common Name can be a pure display name of the party such as OCS Inventory NG Server when using DNS fields
- Ip address can be added to certificate as well using IP field
Always plan the names and IP addresses ahead!
Ok, now we can configure SSL for ocs and apache.
I do have basic SSL Certificate generated using Microsoft PKI using these values:
OU = IT
O = MyCompany Name
S = stateName
C = PLand DNS Names:
I have bundle with .pfx extension so I will need to convert it to Linux .pem/.key format.
I copied the bundle using WinScp into /tmp folder in Debian, now in Shell i enter the tmp folder, convert the bundle and copy it into appropriate directories. Also I need to download and trust my Certification Authority Certificate in Linux(comments are included after //).
- Install OpenSSL and enable SSL in Apache:
Shell12345678apt install openssl -ya2enmod ssl//enable default ssl config for apache:ln -s /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-enabled/default-ssl.conf//restart apache:service apache2 restart
- Convert and install the certificate:
Shell12345678910111213141516171819cd /tmp//convert pfx to pem, provide pfx keyopenssl pkcs12 -in ocsng.pfx -out ocsng.pem -nodes//extract key(provide pfx key once and then new password : 10 chars - twice):openssl pkcs12 -in ocsng.pfx -nocerts -out key.pem//remove key pass from the key (new password)openssl rsa -in key.pem -out ocsng.keycp ocsng.pem /etc/ssl/certs/cp ocsng.key /etc/ssl/private///install root certificate!wget -O /usr/local/share/ca-certificates/root-ca.crt http://somedomain.com/crl/root-ca.cer//update the certificate storeupdate-ca-certificates
- Now we need to adjust Apache configuration to support SSL and secure downloads folder
Shell1234567891011121314151617181920212223242526nano /etc/apache2/sites-enabled/default-ssl.conf//** replace original values with below or adjust them to match below:SSLCertificateFile /etc/ssl/certs/ocsng.pemSSLCertificateKeyFile /etc/ssl/private/ocsng.key//** at the end of file, right before </VirtualHost>Alias /download /var/lib/ocsinventory-reports/download<Directory /var/lib/ocsinventory-reports/download><IfModule mod_authz_core.c># Apache 2.4#Require all deniedRequire host localhostRequire ip 127.0.0.1Require ip 192.168</IfModule><IfModule !mod_authz_core.c>Order deny,allow#Deny from allDeny from allAllow from 127.0.0.1 ::1Allow from 192.168Allow from localhost</IfModule></Directory>
- Now, the second OCS config file:
Shell1234567891011121314151617181920212223242526nano /etc/apache2/conf-enabled/ocsinventory-reports.conf# Uncomment following to force use of HTTPS in Administration Server<Directory /var/lib/ocsinventory-reports/download><IfModule mod_authz_core.c># Apache 2.4#Require all deniedRequire host localhostRequire ip 127.0.0.1Require ip 192.168</IfModule><IfModule !mod_authz_core.c>Order deny,allow#Allow from allDeny from allAllow from 127.0.0.1 ::1Allow from 192.168Allow from localhost</IfModule></Directory>Alias /download /var/lib/ocsinventory-reports/download//restart apacheservice apache2 restart