Προεραιτικά LDAP-TLS.
Για να μπορέσω να δημιουργήσω μια ασφαλή σύνδεση μεταξύ του LDAP εξυπηρετητή και το πελάτη, πρέπει να ενεργοποιήσω την SSL/TLS σύνδεση με το LDAP (θύρα 636). Για να γίνει αυτό απαιτείται ένα πιστοποιητικό x509 για τον εξυπηρετητή. Για τα πιστοποιητικά που χρησιμοποιούνται στο LDAP, επειδή δεν κρυπτογραφούμε το private key του πιστοποιητικού και το κλειδί του πιστοποιητικού περιλαμβάνεται στο πιστοποιητικό, καλό είναι να μη χρησιμοποιούμε self-signed πιστοποιητικά, γιατί αυτά θα μεταφερθούν σε όλα τα μηχανήματα του DOMAIN μας.
Γι αυτό το λόγο χρησιμοποιούμε CA Issued πιστοποιητικά, όπου το CA θα είμαστε πάλι εμείς. Αρχικά λοιπόν δημιουργούμε το φάκελο /etc/ldap/ssl και εγκαθιστούμε το openssl
#apt-get install openssl
#apt-get install ca-certificates
#cd /etc/ldap/ssl
Στη συνέχεια φτιάχνουμε το δικό μας CA x509 πιστοποιητικό:
#/usr/lib/ssl/CA.sh –newca
CA certificate filename (or enter to create)
Making CA certificate ...
Generating a 1024 bit RSA private key
....++++++
.........++++++
writing new private key to './demoCA/private/./cakey.pem'
Enter PEM pass phrase:*******
Verifying - Enter PEM pass phrase:*******
-----
You are about to be asked to enter information that will be incorporated into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value, If you enter '.', the field will be left blank.
Country Name (2 letter code) [AU]:GR
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:LDAP COMPANY
Organizational Unit Name (eg, section) []:DEPT LDAP
Common Name (eg, YOUR name) []:mycertificationauthority.mydomain.gr
Email Address []: Αυτή η διεύθυνση ηλεκτρονικού ταχυδρομείου προστατεύεται από κακόβουλη χρήση. Χρειάζεται να ενεργοποιήσετε την Javascript για να τη δείτε.
Please enter the following 'extra' attributes to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /usr/lib/ssl/openssl.cnf
Enter pass phrase for ./demoCA/private/./cakey.pem:
Check that the request matches the signature
Signature ok
Η διαδικασία αυτή δημιουργεί τα αρχεία demoCA/cacert.pem και demoCA/private/cakey.pem (CA cert και private key). Στη συνέχεια φτιάχνω ένα certificate signing request για τον LDAP εξυπηρετητή χωρίς κρυπτογράφηση για το ιδιωτικό κλειδί (nodes).
Γι αυτό το λόγο χρησιμοποιούμε CA Issued πιστοποιητικά, όπου το CA θα είμαστε πάλι εμείς. Αρχικά λοιπόν δημιουργούμε το φάκελο /etc/ldap/ssl και εγκαθιστούμε το openssl
#apt-get install openssl
#apt-get install ca-certificates
#cd /etc/ldap/ssl
Στη συνέχεια φτιάχνουμε το δικό μας CA x509 πιστοποιητικό:
#/usr/lib/ssl/CA.sh –newca
CA certificate filename (or enter to create)
Making CA certificate ...
Generating a 1024 bit RSA private key
....++++++
.........++++++
writing new private key to './demoCA/private/./cakey.pem'
Enter PEM pass phrase:*******
Verifying - Enter PEM pass phrase:*******
-----
You are about to be asked to enter information that will be incorporated into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value, If you enter '.', the field will be left blank.
Country Name (2 letter code) [AU]:GR
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:LDAP COMPANY
Organizational Unit Name (eg, section) []:DEPT LDAP
Common Name (eg, YOUR name) []:mycertificationauthority.mydomain.gr
Email Address []: Αυτή η διεύθυνση ηλεκτρονικού ταχυδρομείου προστατεύεται από κακόβουλη χρήση. Χρειάζεται να ενεργοποιήσετε την Javascript για να τη δείτε.
Please enter the following 'extra' attributes to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /usr/lib/ssl/openssl.cnf
Enter pass phrase for ./demoCA/private/./cakey.pem:
Check that the request matches the signature
Signature ok
Η διαδικασία αυτή δημιουργεί τα αρχεία demoCA/cacert.pem και demoCA/private/cakey.pem (CA cert και private key). Στη συνέχεια φτιάχνω ένα certificate signing request για τον LDAP εξυπηρετητή χωρίς κρυπτογράφηση για το ιδιωτικό κλειδί (nodes).
#openssl req -newkey rsa:1024 -nodes -keyout newreq.pem -out newreq.pem
Generating a 1024 bit RSA private key
.........................++++++
.......................++++++
writing new private key to 'newreq.pem'
-----
You are about to be asked to enter information that will be incorporated into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value, If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:GR
State or Province Name (full name) [Some-State]:............
Locality Name (eg, city) []:............
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MY COMPANY
Organizational Unit Name (eg, section) []:MY DEPT
Common Name (eg, YOUR name) []:myhost.mydomain.gr
Email Address []: Αυτή η διεύθυνση ηλεκτρονικού ταχυδρομείου προστατεύεται από κακόβουλη χρήση. Χρειάζεται να ενεργοποιήσετε την Javascript για να τη δείτε.
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Στη συνέχεια το CA υπογράφει το certificate request του LDAP εξυπηρετητή:
#/usr/lib/ssl/misc/CA.sh –sign
Using configuration from /etc/ssl/openssl.cnf
Enter PEM pass phrase:
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
Μετακινούμε τα παρακάτω αρχεία στο φάκελο /etc/ldap/ssl
#cp /etc/ldap/ssl/demoCA/cacert.pem /etc/ldap/ssl/
#cp /etc/ldap/ssl/newcert.pem /etc/ldap/ssl/ldap-server.pem
#cp /etc/ldap/ssl/newreq.pem /etc/ldap/ssl/ldap-server-key.pem
#chmod 400 /etc/ldap/ssl/ldap-server-key.pem
Η τελευταία εντολή κάνει το private key μη αναγνώσιμό εκτός από το διαχειριστή. Με την ίδια διαδικασία χρησιμοποιόντας το CA που έχουμε ήδη δημιουργήσει φτιάχνουμε πιστοποιητικά και κλειδιά και για τους πελάτες(Workstations). Mετά ανοίγουμε το configuration αρχείο /etc/ldap/slapd.conf του LDAP εξυπηρετητή και προσθέτουμε τις εξής γραμμές κάτω ακριβώς από τα schema:
TLSCipherSuite HIGH:MEDIUM:+SSLv2
TLSCACertificateFile /etc/ldap/ssl/cacert.pem
TLSCertificateFile /etc/ldap/ssl/ldap-server.pem
TLSCertificateKeyFile /etc/ldap/ssl/ldap-server-key.pem
# Use the following if client authentication is required
#TLSVerifyClient demand
# ... or not desired at all
TLSVerifyClient never ; Δεν θέλω να κάνω verify certificate των clients, αλλιώς demand.
Τέλος τροποποιώ το αρχείο /etc/ldap/ldap.conf ως εξής:
HOST localhost
PORT 636
BASE dc=ldap,dc=myhost,mydomain,dc=gr
TLS_CACERT /etc/ldap/ssl/cacert.pem
TLS_REQCERT demand
SIZELIMIT 0
TIMELIMIT 300
Εδώ τελειώνει το αρχικό configuration του slapd.conf. κλείνουμε το αρχείο και επανεκινουμε τον LDAP δαίμονα, παρακολουθώντας τo log file /var/log/ldaplogs :
#/etc/init.d/slapd start
#tail –f /var/log/ldaplogs
slapd[1471]: slapd starting
#netstat –an
tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:636 0.0.0.0:* LISTEN
Το SAMBA χρησιμοποιεί το πακέτο SSLEAY για να προσφέρει SSL υποστήριξη στον εξυπηρετητή. Λόγω όμως του “US export law”, το SAMBA δεν μπορεί να ενωθεί με το SSLEAY και κυκλοφορεί σαν ξεχωριστό πακέτο. Για να το εγκαταστήσω κάνω τα εξής:
Generating a 1024 bit RSA private key
.........................++++++
.......................++++++
writing new private key to 'newreq.pem'
-----
You are about to be asked to enter information that will be incorporated into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value, If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:GR
State or Province Name (full name) [Some-State]:............
Locality Name (eg, city) []:............
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MY COMPANY
Organizational Unit Name (eg, section) []:MY DEPT
Common Name (eg, YOUR name) []:myhost.mydomain.gr
Email Address []: Αυτή η διεύθυνση ηλεκτρονικού ταχυδρομείου προστατεύεται από κακόβουλη χρήση. Χρειάζεται να ενεργοποιήσετε την Javascript για να τη δείτε.
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Στη συνέχεια το CA υπογράφει το certificate request του LDAP εξυπηρετητή:
#/usr/lib/ssl/misc/CA.sh –sign
Using configuration from /etc/ssl/openssl.cnf
Enter PEM pass phrase:
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
Μετακινούμε τα παρακάτω αρχεία στο φάκελο /etc/ldap/ssl
#cp /etc/ldap/ssl/demoCA/cacert.pem /etc/ldap/ssl/
#cp /etc/ldap/ssl/newcert.pem /etc/ldap/ssl/ldap-server.pem
#cp /etc/ldap/ssl/newreq.pem /etc/ldap/ssl/ldap-server-key.pem
#chmod 400 /etc/ldap/ssl/ldap-server-key.pem
Η τελευταία εντολή κάνει το private key μη αναγνώσιμό εκτός από το διαχειριστή. Με την ίδια διαδικασία χρησιμοποιόντας το CA που έχουμε ήδη δημιουργήσει φτιάχνουμε πιστοποιητικά και κλειδιά και για τους πελάτες(Workstations). Mετά ανοίγουμε το configuration αρχείο /etc/ldap/slapd.conf του LDAP εξυπηρετητή και προσθέτουμε τις εξής γραμμές κάτω ακριβώς από τα schema:
TLSCipherSuite HIGH:MEDIUM:+SSLv2
TLSCACertificateFile /etc/ldap/ssl/cacert.pem
TLSCertificateFile /etc/ldap/ssl/ldap-server.pem
TLSCertificateKeyFile /etc/ldap/ssl/ldap-server-key.pem
# Use the following if client authentication is required
#TLSVerifyClient demand
# ... or not desired at all
TLSVerifyClient never ; Δεν θέλω να κάνω verify certificate των clients, αλλιώς demand.
Τέλος τροποποιώ το αρχείο /etc/ldap/ldap.conf ως εξής:
HOST localhost
PORT 636
BASE dc=ldap,dc=myhost,mydomain,dc=gr
TLS_CACERT /etc/ldap/ssl/cacert.pem
TLS_REQCERT demand
SIZELIMIT 0
TIMELIMIT 300
Εδώ τελειώνει το αρχικό configuration του slapd.conf. κλείνουμε το αρχείο και επανεκινουμε τον LDAP δαίμονα, παρακολουθώντας τo log file /var/log/ldaplogs :
#/etc/init.d/slapd start
#tail –f /var/log/ldaplogs
slapd[1471]: slapd starting
#netstat –an
tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:636 0.0.0.0:* LISTEN
Το SAMBA χρησιμοποιεί το πακέτο SSLEAY για να προσφέρει SSL υποστήριξη στον εξυπηρετητή. Λόγω όμως του “US export law”, το SAMBA δεν μπορεί να ενωθεί με το SSLEAY και κυκλοφορεί σαν ξεχωριστό πακέτο. Για να το εγκαταστήσω κάνω τα εξής:
#apt-get install libnet-ssleay-perl libauthen-pam-perl libio-pty-perl libmd5-perl
Toποθετούμε στο /etc/samba/smb.conf τα εξής:
Toποθετούμε στο /etc/samba/smb.conf τα εξής:
ssl=yes
ssl server cert = /etc/certificates/cacert.pem
ssl server key = /etc/certificates/private/cakey.pem
ssl cA certDir = /etc/certificates
ssl server cert = /etc/certificates/cacert.pem
ssl server key = /etc/certificates/private/cakey.pem
ssl cA certDir = /etc/certificates
Tags: ssl/tls self-signed openssl ca x509 req newreq dn key pem TLSCipherSuite CACERT REQCERT SSLEAY
| < Προηγούμενο | Επόμενο > |
|---|















nice
nice
Borse Designer,Gucci Sito Ufficiale http://www.guccioutletsito2012....
Borse Designer,Gucci Sito Ufficiale conosciuto per essere il miglio...