加分大奉送!关于https协议 (以后我还会给你家分!)

ghw 2001-03-27 06:44:00
请教各位大虾:

我写如下代码,在jdk1.3中编译通不过,请指教!

import java.net.*;

URL url=new URL("https://127.0.0.1:80/index.html");

错误指出在net包中没有 https 协议,我到哪里可以得到包含https协议的包!

...全文
361 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
ghw 2001-03-30
  • 打赏
  • 举报
回复
请教路人甲:

你能否将你测试过的程序,转发给我,一定要说详细那些安全方面的配置,
我第一次使用ssl,不知道怎样配置ssl,还有我如何申请可信任的ca证书。

请多帮忙啊!

由于网速太慢,往我的mail中发吧

Email: mikehelp@china.com

谢谢!

请各路java剑客多关照!
skyyoung 2001-03-29
  • 打赏
  • 举报
回复
这个例子我以前测试过(jsse1.0.2),可以用。
关注!
lmy2000 2001-03-29
  • 打赏
  • 举报
回复
对不起没看清是编译错误,那应该不是上面所说。还是安全设置的问题?
lmy2000 2001-03-29
  • 打赏
  • 举报
回复
是不是你的所请求的服务端没有可信任的ssl配置?(从报错说:没有可信任的服务器证书链)
如果这样的话需要先配置你的服务端的ssl.如:luodi(无知者无畏)所说,需要向可信任的ca申请证书。
lmy2000 2001-03-29
  • 打赏
  • 举报
回复
是不是你的所请求的服务端没有可信任的ssl配置?(从报错说:没有可信任的服务器证书链)
luodi 2001-03-28
  • 打赏
  • 举报
回复
如果是在IE或Netscape的Applet中使用的话,是不需要 JSSE 扩展包的,楼上几位讲的端口问题可能是关键所在。

如果你是想实现一个Java Application中使用SSL的话,可以象楼上几位讲的去找一个JSSE,但是还有别的免费的实现更好,不过不管怎样,你还必须熟悉一下Java中的Keytool,以及java.security.properties的设置方法,还要去申请一个证书,还是比较烦的。:)
lmy2000 2001-03-28
  • 打赏
  • 举报
回复
对,需要引入ssl包,masterz()想的也有一定道理,注意https的端口不要指定为80
skyyoung 2001-03-28
  • 打赏
  • 举报
回复
import javax.net.ssl.*

同意一楼讲法
ghw 2001-03-28
  • 打赏
  • 举报
回复
各位大侠帮忙啊
ghw 2001-03-28
  • 打赏
  • 举报
回复
各位大侠帮忙啊
ghw 2001-03-28
  • 打赏
  • 举报
回复
java.security 配置如下(在原来的基础上加了一行)
security.provider.3=com.sun.net.ssl.internal.ssl.Provider

源程序:
import java.net.*;
import java.io.*;
import java.security.*;
import javax.net.ssl.*;

public class getxml
{
public static void main(String args[])
{
try
{
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
URL u=new URL("https://www.verisign.com/");

BufferedReader br_html=new BufferedReader(new InputStreamReader(u.openStream()));
String s_line_temp,s_result="";
while((s_line_temp=br_html.readLine())!=null)
{
s_result+=(s_line_temp+"\n");
}
System.out.println(s_result);

}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}


编译后,出现问题如下:
***
main, SEND SSL v3.1 ALERT: fatal, description = certificate_unknown
main, WRITE: SSL v3.1 Alert, length = 2
javax.net.ssl.SSLException: untrusted server cert chain
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a([DashoPro-V1.2-120198])
at com.sun.net.ssl.internal.ssl.ClientHandshaker.a([DashoPro-V1.2-120198
])
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage([DashoPr
o-V1.2-120198])
at com.sun.net.ssl.internal.ssl.Handshaker.process_record([DashoPro-V1.2
-120198])
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a([DashoPro-V1.2-120198])
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a([DashoPro-V1.2-120198])
at com.sun.net.ssl.internal.ssl.AppOutputStream.write([DashoPro-V1.2-120
198])
at java.io.OutputStream.write(OutputStream.java:61)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake([DashoPro-V
1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.doConnect([Da
shoPro-V1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.NetworkClient.openServer(
[DashoPro-V1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpClient.l([DashoPro-V1
.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpClient.<init>([DashoP
ro-V1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.<init>([Dasho
Pro-V1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V
1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V
1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.connec
t([DashoPro-V1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.getInp
utStream([DashoPro-V1.2-120198])
at java.net.URL.openStream(URL.java:798)


我该怎么办?
masterz 2001-03-27
  • 打赏
  • 举报
回复
改成URL url=new URL("https://127.0.0.1/index.html");如何
mzer 2001-03-27
  • 打赏
  • 举报
回复
you can see http://java.sun.com
there are a "jsse"---package about https!

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧