Linux Ubuntu: importing the server certififcate, no keytool command?
Asked by esome:

*This question is in reference to Atlassian Documentation: [Configuring an SSL Connection to Active Directory](https://confluence.atlassian.com/pages/viewpage.action?pageId=229838458)*

This question is in reference to Atlassian Documentation: Configuring an SSL Connection to Active Directory  
Hello Community,  
I have a problem to connect confluence to our Microsoft AD Server with write/read option via SSL (LDAPS). Every time I try to do a quick test, after enabling the option "Use SSL" in the "Configure LDAP User Directory" Dialog with "Read/Write"-Permission, i get the following message after pressing the "Quick Test"-Button:

##############  
Connection test failed. Response from the server:  
[ad1.domain.com](http://ad1.domain.com):636; nested exception is javax.naming.CommunicationException: [ad1.domain.com](http://ad1.domain.com):636 \[Root exception is [javax.net](http://javax.net).ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target\]  
##############

Without the ssl-option the test passes. At the moment (without enabled ssl option) it is possible for us to login via Windows AD login credentials into confluence. But we want the ability to change the windows AD user password via confluence. So I think the ssl connection is required for this intentions.

So what is the problem? What do i have to change?

I've tried to import our ad1-Server-Cert (filename ad1.crt) on our confluence server (actual Ubuntu Linux 64-bit edition) and followed the manual *[Configuring an SSL Connection to Active Directory](https://confluence.atlassian.com/pages/viewpage.action?pageId=229838458)* but for me it is not possible to import our ad1-Serer-Cert. After trying the command "sudo keytool -importcert -keystore ./cacerts -file ad1.crt" I'm getting the following error message "sudo: keytool: Command not found". I've copied the ad1.crt file to the following directory "/opt/atlassian/confluence/jre/lib/security".  
I've installed confluence via the Linux Installer file (atlassian-confluence-5.9-10-x64.bin), I used the "Express Install"-Option.

Thank you very much!

Kind regards,  
Matthias


Answers:
author: esome
body: Thank you for your quick response. There is no variable $JAVA_HOME. Yesterday I read, that JRE will be installeg automatically via the Linux installer and Express Installation option.

I've tried the following two commands:

sudo $JAVA_HOME/keytool -importcert -keystore ./cacerts -file ad1.crt

sudo $JRE_HOME/keytool -importcert -keystore ./cacerts -file ad1.crt

result: /keytool: Command not found

Do I have to set up the variable $JAVA_HOME ? I thought the installer will do it for me?

Thanks. Matthias

comments: author: Jonas Andersson
body: do this:

```
ps axuww | grep java | grep jira#here you should be able to see which java it uses to start jira#update the mlocate databasesudo updatedb#search for the keytoollocate keytool#then use the direct path that it finds for keytool. Make sure it's in the same path as the java used to start jira.
```

Additionally, it makes sense to do an

export JAVA_HOME="/path/to/jdk"

in .bashrc, .profile, /etc/profile or any other files used to set up the JIRA users environment, as this path also refers to cacert files and other candy that your system will use if/when using SSL.


author: Jonas Andersson
body: ps. "/path/to/jdk" should be replaced with the dir to your JDK.

If it finds your keytool in: /opt/java/jdk1.8.0_65/bin/keytool

your JAVA_HOME should be set to: /opt/java/jdk1.8.0_65/

Additionally, if the java that executed JIRA is in /opt/atlassian/jira/... it uses the bundled JRE instead of a JDK. In that case there is no use to set the JAVA_HOME as JIRA already is aware of it anyway.


author: Jonas Andersson
body: And by JIRA, i mean confluence :smile:


author: Matthias Wolf
body: Thank you for your help. I've found the right directories (keytool + cert-dir) and imported our ad1.crt file succesfully. From now on the SSL connection (read/write) works! User can now change their Windows AD password via confluence.

Kind regards,

Matthias


author: Nic Brough -Adaptavist-
body: If you are using a relatively recent version of Confluence, then it has shipped with, and installed, Java for you.

You should be able to go to \<confluence installation\> and do it all within that. A quick look at my install that's using certs is below. You'll need to specify the right paths if you leave your Java home blank

nic@[zen:/opt/confluence/jre$](http://zen/opt/confluence/jre$) echo $JAVA_HOME  

nic@[zen:/opt/confluence/jre$](http://zen/opt/confluence/jre$) find . \| egrep "cacerts\|keytool"  
./lib/security/cacerts  
./man/man1/keytool.1  
./man/ja_JP.UTF-8/man1/keytool.1  
./bin/keytool


author: Jonas Andersson
body: Command not found speaks for itself.. Try replacing the 'keytool' with '$JAVA_HOME/keytool' and it should work.


Tags: ssl