JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Application Server » Tomcat  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to postflat modego to previous topicgo to next topic
己加入精華區
by koji at 2007-12-12 17:25
本主題所含的標籤
無標籤
作者 Re:Tomcat SSL 問題 [Re:secretguest0824]
secretguest0824

別當出頭鳥



發文: 354
積分: 1
於 2006-12-22 17:09 user profilesend a private message to usersend email to secretguest0824reply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
各位大大,小弟又試了一次,雖然還有問題,但總算有所進展!
先將步驟列出如下:
1.Server.xml沒有改,但我重新產生一次.keystore:
C:\Program Files\Java\jdk1.5.0_10\bin>keytool -genkey -alias tomcat -keyalg RSA
輸入 keystore 密碼: admin123
您的名字與姓氏為何?
[Unknown]: localhost這個好像不能亂打,要打domain name..
您的編制單位名稱為何?
[Unknown]: fpg
您的組織名稱為何?
[Unknown]: fpg
您所在的城市或地區名稱為何?
[Unknown]: fpg
您所在的州及省份名稱為何?
[Unknown]: fpg
該單位的二字國碼為何
[Unknown]: tw
CN=localhost, OU=fpg, O=fpg, L=fpg, ST=fpg, C=tw 正確嗎?
[否]: Y
輸入 <tomcat> 的主密碼
(RETURN 如果和 keystore 密碼相同): admin123

2.當然它還是產生在C:\Documents and Settings\xxx下,我就把它複製到C:\Program Files\Java\jdk1.5.0_10\bin

3.到http://www.verisign.com/support/verisign-intermediate-ca/Trial_Secure_Server_Root/index.html複製文字(Root CA Certificates)存在C:\Program Files\Java\jdk1.5.0_10\bin\root.cer

4.將root.cer加到.keystore中:
C:\Program Files\Java\jdk1.5.0_10\bin>keytool -import -alias root -keystore .key
store -trustcacerts -file root.cer
輸入 keystore 密碼: admin123
Owner: CN=VeriSign Trial Secure Server Test Root CA, OU="For Test Purposes Only.
No assurances.", O="VeriSign, Inc.", C=US
發照者: CN=VeriSign Trial Secure Server Test Root CA, OU="For Test Purposes Onl
y. No assurances.", O="VeriSign, Inc.", C=US
序號: 20a897aedb8202dec136a04e26bd8773
有效期間: Wed Feb 09 08:00:00 CST 2005 直到: Sun Feb 09 07:59:59 CST 2025
認認指紋:
MD5: B6:9D:A4:40:52:02:50:0DBig Smile5:9C:E1:B8:4B:66:C4:AC
SHA1: 81:A7:B1:CA:51:66Big Smile1:2D:CB:32:CA:00:21:C3:9E:49:54:73:56:65
信任這個認證? [否]: Y
認證已新增至 keystore 中

5.然後以https://localhost:8443/測試,出現安全性警告視窗,除了說這個憑證尚未被信任外,另外兩個都ok,按"是"就可以正常瀏覽了

6.但我用程式去傳送檔案測試卻出現sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
這是怎麼回事ㄚ?我的程式碼如下...懇請大大指點....
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
public boolean Send(File file,String strSuccessMessage) throws NetworkErrorException
  {
    boolean boolRetrun = false;
    try
    {
      
      URLConnection urlConn = url.openConnection();
    
      urlConn.setDoInput(true);
      urlConn.setDoOutput(true);
      urlConn.setUseCaches(false);
      urlConn.setRequestProperty("Content-Type","text/xml");
      
        FileInputStream bf=new FileInputStream(file);
      // Send POST output.
        DataOutputStream printout = new DataOutputStream(urlConn.getOutputStream());
       
        byte[] buf = new byte[2048];
      int num = bf.read(buf);
      while (num != (-1))// 是否讀完文件 
      {  
        printout.write(buf, 0, num);// 把文件內容寫到網路緩衝區
        num = bf.read(buf);// 繼續從文件中讀取數據
 
      }
      printout.flush();// 把緩衝區的數據寫往客戶端
      bf.close();
      printout.close();
      
      BufferedReader input = new BufferedReader(new InputStreamReader(
          urlConn.getInputStream()));
      String str = input.readLine().trim();
      if (str.equals(strSuccessMessage)) {
        boolRetrun = true;
      } else {
        boolRetrun = false;
      }
    }  
    catch(IOException ce)      // 網路傳輸斷線
    {
      if(TroubleDetector.DetectServer(this.url.getHost(), 80));
        throw new NetworkErrorException("網路發生問題!!",ce);
      
    }
    catch(Exception ce)
    {
      ce.printStackTrace();
      throw new NetworkErrorException("傳輸檔案發生問題!!",ce);
    }
    
    return boolRetrun;
  }


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
15609 [精華] Tomcat SSL 問題 secretguest0824 1298 2006-12-22 14:50
13474 Re:Tomcat SSL 問題 secretguest0824 3255 2006-12-22 17:09
7042 Re:Tomcat SSL 問題 zrjian 89 2009-05-21 17:12
6976 Re:Tomcat SSL 問題 secretguest0824 201 2009-05-21 17:21
7022 Re:Tomcat SSL 問題 zrjian 439 2009-05-21 17:54
6988 Re:Tomcat SSL 問題 secretguest0824 763 2009-05-21 18:19
6954 Re:Tomcat SSL 問題 zrjian 664 2009-05-21 19:03
7064 Re:Tomcat SSL 問題 zrjian 168 2009-05-25 10:49
13792 Re:Tomcat SSL 問題 secretguest0824 1700 2006-12-25 14:34
13088 Re:Tomcat SSL 問題 secretguest0824 2543 2006-12-26 17:45
13001 Re:Tomcat SSL 問題 secretguest0824 69 2006-12-26 17:49
13055 Re:Tomcat SSL 問題 secretguest0824 109 2006-12-26 18:19
10651 Re:Tomcat SSL 問題 secretguest0824 227 2007-12-12 15:50
10892 Re:Tomcat SSL 問題 secretguest0824 713 2007-12-12 16:29
10680 Re:Tomcat SSL 問題 frankiakimo 46 2008-01-02 10:05
6546 Re:Tomcat SSL 問題 porsa 228 2009-07-29 17:54
6509 Re:Tomcat SSL 問題 tuu 375 2009-07-29 23:03
6512 Re:Tomcat SSL 問題 porsa 944 2009-07-30 09:09
7297 Re:Tomcat SSL 問題 tuu 331 2009-07-30 09:58
» JWorld@TW »  Application Server » Tomcat

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8