In the field I've often come across the issue where we need the TrustedRoot certificate and we have no eDirectory management tools available or we do not have the Certificate Server snapins installed in either iManager or ConsoleOne. The solution outlined here, exports the TrustedRoot certificate by using standard Linux tools.
The TrustedRoot certificate is stored on every certificate in eDirectory. The encoding type is base64. By default two certificates are created per eDirectory server. The certificates are placed in the same container as the server object. The issue here is that the server location is undetermined, since it can be any container, and that the names of these certificates contain the servername which is also undetermined.
The TrustedRoot certificate is also stored on the Certificate Authority (CA) object. This attribute is not accessible by standard management tools but the place is always the cn=Security container. This makes it faster and easier to search for- and to extract the certificate. The certificate is stored in base64 format in the attribute cACertificate. This solution extracts the certificate, manipulates it with some sed and openssl commands (explained below) and exports it in der format just like you would do with iManager or ConsoleOne.
To cut a long story short, this is the complete command used;
# /usr/bin/ldapsearch -H ldaps://se-nds62.consulting.novell.com:636 -D cn=Admin,o=Novell -wnovell -b cn=Security cn=*\ CA cACertificate -x -LLL | grep -v "dn:" | sed "s/cACertificate:://g" | sed 's/ //g' |openssl base64 -d |openssl x509 -inform der -out /opt/novell/TrustedRootCert_ONE-TWO-TREE.der -outform der
If you want to script this, you could use the following (when copy-pasting the script, take care that no additional characters follow the "\" backslashes otherwise script execution will fail);
# purpose : Extracting the TrustedRoot certificate from eDirectory with basic command line Linux tools.
# project : Novell Consulting Netherlands
# section : Tooling
# filename : GetTRc.sh
# date : April 15, 2008 (080415)
# version : v1.0
# function : This Linux script extracts the TrustedRoot Certificate from the eDirectory's
# Certificate Authority (CA) and saves it in der format.
# remarks : -
# history : v1.0 inital version
# author : J. Moerenhout, Novell Consulting Netherlands
/usr/bin/ldapsearch -x -LLL -H ldaps://$HOSTNAME:636 -D $USERNAME -w$PASSWORD -b cn=Security cn=*\ CA cACertificate \
| grep -v "dn:" \
| sed "s/cACertificate:://g" \
| sed 's/ //g' \
| openssl base64 -d \
| openssl x509 -inform der -out /opt/novell/$CERTNAME -outform der
Explanation of commands used;
- extract the cACertificate attribute from the Certificate Authority object by /usr/bin/ldapsearch -x -LLL -H ldaps://$HOSTNAME:636 -D $USERNAME -w$PASSWORD -b cn=Security cn=*\ CA cACertificate
- /usr/bin/ldapsearch is the ldapsearch command to use, we deliberately use the openldap ldapsearch command since the openssl version can be configured to ignore ssl (assuming we haven't got the TrustedRoot certificate yet, we can't use the eDirectory version since this requires the TrustedRoot certificate to do an successful SSL bind)
-x to use simple authentication (ignore the SSL certificates)
-LLL to export in LDIF format without comments and version
-H is the LDAP URI of the LDAP server, we connect to port 636
-D is the bind name, we used Admin here, there is no real need to use Admin, any user can be used since the CA object and cACertificate attribute can be read by any user
-w is the password (can also be -W where you will be asked to specify the password on the commandline)
-b cn=Security is the base search container
cn=*\ CA cACertificate \ is the search parameter, we search for the name containing "CA" (the CA contains the tree name in it's name, by searching for *\ CA, any CA is found) and list the cACertificate attribute
- ldapsearch exports the dn at the beginning, grep -v "dn:" is used to remove the line with the dn in it
- ldapsearch exports the attribute name at the beginning, sed "s/cACertificate:://g" is used to remove the text "cACertificate"
- ldapsearch exports data 80 characters wide and adds a space at the beginning of each line where the data continues, sed 's/ //g' is used to remove the leading spaces
- the data in eDirectory is stored in base64 format, use openssl base64 -d to decode the data from base64
- after we decoded the data, use openssl x509 -inform der -out /opt/novell/$CERTNAME -outform der to encode it in x509 format again and export the data in der format
The TrustedRoot certificate of the tree specified is now stored in /opt/novell.
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.