我是一个完整的初学者,我已经尝试与服务器建立连接已有一段时间了
public class Test {
public static void main(String[] args) throws ClientProtocolException, IOException {
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getCredentialsProvider().setCredentials(
new AuthScope("9.5.127.34", 80),
new UsernamePasswordCredentials("root", "passw0rd"));
String url_copied_from_firebug = "https://9.5.127.34/powervc/openstack/volume/v1/115e4ad38aef463e8f99991baad1f809//volumes/3627400b-cd98-46c7-a7e2-ebce587a0b05/restricted_metadata"
HttpGet httpget = new HttpGet(url_copied_from_firebug);
HttpResponse response = httpClient.execute(httpget);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
}
我尝试运行代码时遇到的错误是
线程“主”javax.net.ssl.SSLPeerUnverifiedException 中的异常:对等体未通过身份验证
我尝试将端口号从 80 更改为 443,但它不起作用。我想我是从它开始的,可能会遗漏很多东西。请指出我正确的方向。
提前谢谢。