2013-06-19 84 views
2

我試圖在沒有運氣的情況下在ahsayobs上設置SSL。第一步是刪除機器上安裝的默認證書。我正在運行Java版本1.6。下面是我在做什麼:keytool錯誤:java.lang.RuntimeException:使用錯誤,-delete不是合法的命令

[[email protected] ~]# /data/obs_6.5/java-linux-x86/bin/keytool –delete –alias tomcat –keystore /Applications/AhsayOBS/conf/keystore 
keytool error: java.lang.RuntimeException: Usage error, –delete is not a legal command 
[[email protected] ~]# /data/obs_6.5/java-linux-x64/bin/keytool –delete –alias tomcat –keystore /Applications/AhsayOBS/conf/keystore 
keytool error: java.lang.RuntimeException: Usage error, –delete is not a legal command 
[[email protected] ~]# /data/obs/java-linux-x64/bin/keytool –delete –alias tomcat –keystore /Applications/AhsayOBS/conf/keystore 
keytool error: java.lang.RuntimeException: Usage error, –delete is not a legal command 

下一個步驟是創建CSR也回來與Usage error, –genkey is not a legal command。這就像是keytool甚至沒有安裝。但我沒有得到那個錯誤,並且locate keytool顯示了它的一些不同的位置(我已經嘗試了它們)。每個人都顯示相同的錯誤。關於我在做什麼的任何想法都是錯誤的?

編輯

哦geesh ......看來這個文章中,我已經複製/粘貼從命令(密鑰工具-delete -alias ...等),沒有使用常規的連字符,那就是是什麼把它扔掉了。以下是我用到底:

### First, delete the previous keystore file 
/data/obs_6.5/java-linux-x86/bin/keytool -delete -alias tomcat -keystore /data/obs/conf/keystore 

### Then, create a new keystore file 
/data/obs_6.5/java-linux-x86/bin/keytool -genkey -alias tomcat -keyalg RSA -keysize 2048 -keystore /data/obs/conf/keystore 

### You will be asked for normal SSL info such as your name, department, company, etc. 

/data/obs_6.5/java-linux-x86/bin/keytool -certreq -keyalg RSA -alias tomcat -keystore /data/obs/conf/keystore 

### Save the intermediate certificate and the SSL certificate into the /data/obs/conf/ folder 
### Use the below commands to import them into the keytool 
/data/obs_6.5/java-linux-x86/bin/keytool -import -alias intermed -trustcacerts -file sf_intermediate.crt -keystore /data/obs/conf/keystore 
/data/obs_6.5/java-linux-x86/bin/keytool -import -alias tomcat -trustcacerts -file backup.atomicx.com.crt -keystore /data/obs/conf/keystore 

### Check the keytool to make sure it was successful 
/data/obs_6.5/java-linux-x86/bin/keytool -list -alias tomcat -keystore /data/obs/conf/keystore 

### Make sure /data/obs/conf/server.xml has the correct keystore folder path 
<-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 --> <!-- <Connector port="8443" maxThreads="200" 
scheme="https" secure="true" SSLEnabled="true" 
keystoreFile="path to your keystore file" keystorePass="changeit" clientAuth="false" sslProtocol="TLS"/> 
+0

儘管我不是Linux的專家,但是您確定您有權運行keytool嗎?另一個嘗試是從它所在的目錄中直接運行keytool。 –

+0

@SergioPelin謝謝Sergio,但我實際上是從它所在的目錄,在沒有運氣的每個目錄中運行它(見上文)。雖然我沒有檢查權限。但是,是的,我以root身份登錄,root擁有執行權限。 – James

回答

3

我發現我在那裏複製和粘貼命令,連字符實際上沒有連字符,但長破折號。一旦我取代了這些,我就不會再犯這個錯誤了。然而,這裏是我所做的所有事情,以防萬一需要。

### First, delete the previous keystore file 
/data/obs_6.5/java-linux-x86/bin/keytool -delete -alias tomcat -keystore /data/obs/conf/keystore 

### Then, create a new keystore file 
/data/obs_6.5/java-linux-x86/bin/keytool -genkey -alias tomcat -keyalg RSA -keysize 2048 -keystore /data/obs/conf/keystore 

### You will be asked for normal SSL info such as your name, department, company, etc. 

/data/obs_6.5/java-linux-x86/bin/keytool -certreq -keyalg RSA -alias tomcat -keystore /data/obs/conf/keystore 

### Save the intermediate certificate and the SSL certificate into the /data/obs/conf/ folder 
### Use the below commands to import them into the keytool 
/data/obs_6.5/java-linux-x86/bin/keytool -import -alias intermed -trustcacerts -file sf_intermediate.crt -keystore /data/obs/conf/keystore 
/data/obs_6.5/java-linux-x86/bin/keytool -import -alias tomcat -trustcacerts -file backup.atomicx.com.crt -keystore /data/obs/conf/keystore 

### Check the keytool to make sure it was successful 
/data/obs_6.5/java-linux-x86/bin/keytool -list -alias tomcat -keystore /data/obs/conf/keystore 

### Make sure /data/obs/conf/server.xml has the correct keystore folder path, and that it uses the same password that you set earlier 
<-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 --> <!-- <Connector port="8443" maxThreads="200" 
scheme="https" secure="true" SSLEnabled="true" 
keystoreFile="path to your keystore file" keystorePass="changeit" clientAuth="false" sslProtocol="TLS"/>