java - java.net.UnknownHostException 打开到 https 站点的连接
问题描述
自从我开始 Java 编程以来已经一个月了。与此同时,我正在研究在经过身份验证的代理单元上运行的 java fx webview。我能够在运行此代码的 http 站点上连接:
Properties systemSettings = System.getProperties();
String User = "myusername";
String Password = "mypassword";
systemSettings.put("proxySet", "true");
systemSettings.put("https.proxyHost", "192.1.1.20");
systemSettings.put("https.proxyPort", "8888");
systemSettings.put("http.proxyHost", "192.1.1.20");
systemSettings.put("http.proxyPort", "8888");
Authenticator.setDefault(new ProxyAuthenticator(User ,Password));
HttpURLConnection conn = (HttpURLConnection) new URL("http://www.google.com/").openConnection();
String encodedUserPwd = Base64Converter.encode("myuser:mypassword".getBytes());
conn.setRequestProperty("Proxy-Authorization", "Basic " + encodedUserPwd);
conn.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
}
WebView webView = new WebView();
WebEngine engine = webView.getEngine();
engine.load("http://www.google.com/");
VBox root = new VBox();
root.getChildren().addAll(webView);
Scene scene = new Scene(root, 1200, 700);
primaryStage.setScene(scene);
primaryStage.show();
in.close();
但如果我将 url 更改为 https,它会抛出 java.net.UnknownHostException。需要帮忙。
解决方案
推荐阅读
- ssis - 将 csv 文件写入 Azure Blob 存储时,是否可以将 SSIS 配置为将 NULL 表示为 BLANK 而不是 \N?
- angular - 如何在 OnInit 之后更新视图上的属性绑定?(角度)
- oracle - 删除并重新创建表上具有列表分区的全局索引
- python-3.x - 将numpy数组的每个2字符字符串元素拆分为1字符字符串元素的最快方法?
- angular - 代码推送发布良好,但未到达应用程序
- excel - 将 VLOOKUP 用于十进制数时 Excel 中的 N/A 问题
- vuejs2 - 为什么,当您在 v-select 之外单击时,v-model 会重置为 null?验证
- javascript - 如何将数组的元素放在单独的 div 中的数组内的对象内?
- java - 如何更改偏好片段中偏好的文本颜色?
- python - 为什么我会从 AWS API Gateway 收到 Forbidden 消息,即使内部工作正常?