java无法验证证书,如何解决"该证书无效,并且不能用来验证本网站&QUOT的身份;错误?...

The question is, How to solve "The certificate is not valid and cannot be used to verify the identity of this website" error?.

Here are the details:

I have a signed applet that has been working fine, until I updated Java to 8u25 (1.8.0_25-b18). Now, the application shows an alert message "Do you want to continue? The connection to this website is untrusted". There is a note in this message too, "The certificate is not valid and cannot be used to verify the identity of this website".

The applet is loaded without problems. But when the user tries to use a specific function of that application, the warning message is displayed.

I've checked the java console when this happens, and this warning message is displayed right after these lines:

security: Obtain certificate collection in SSL Root CA certificate store

security: Invalid certificate from HTTPS server

network: Cache entry not found [url: https://sub.domain.net:9876, version: null]

The application is downloaded from a different domain, say "https://app.domain.net/.....", so no jars are downloaded from "https://sub.domain.net:9876", but the applet connects to "https://sub.domain.net:9876" to send/receive data.

The applet is signed correctly, and so far, it meets all the security requirements according to Java. This issue seems to happen when the application tries to connect internally with an HTTPS url like https://sub.domain.net:9876. That sites' SSL certificate is valid, issued by GoDaddy and has not expired.

Again, this started to happen after updating my JRE to 8u25. I've tested adding the offending URL to Java security exception list, with no success.

Here are a few screenshot of this problem:

This is the warning message displayed:

fMdYC.png

8XdAz.png

uyH4D.png

UqHKn.png

Edit 10/18/2014:

Question posted in "Oracle Community" too, to increase answer options:

Question in Oracle Community.

Edit 10/21/2014:

I noticed this: When I click the link "More Information" displayed in the "Security Warning" dialog, the reason displayed says:

The application is being downloaded from a site other than the one

specified by the security certificate.

Downloading from "sub.domain.net"

Expecting "*.DOMAIN.NET"

This message says the application is BEING DOWNLOADED FROM "sub.domain.com", and that is false. The application (applet) is already downloaded, and it is only using that domain in an internal HTTPS request, to get/send business data, not to download additional Jars, JNLPs, etc.

解决方案

I found how to solve this issue, and thanks to Steffen Ullrich for a valid proposal.

This is related to the certificate's Common Name (CN) value. In my case, that value was *.DOMAIN.NET, and to change it to *.domain.net, all we had to do was a procedure called "Domain Transfer". This means, to change the CN to *.REKEY.DOMAIN.NET, and then to change it again to *.domain.net. We could not change it to *.domain.net directly because the certificate provider says *.DOMAIN.NET and *.domain.net are the same.

Now, this issue happened only with Java 7.71 and Java 8.25. Previous version of Java 7 and 8 don't have this issue (SSL certificate restrictions for CN in a different casing).

Anyway, this solved the issue, and now we receive a gentle information message about the domain:

yUoSO.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以在导出Excel时,将双引号替换为",可以使用Java中的字符串替换方法来实现。以下是一个简单的示例代码: ```java import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.io.FileOutputStream; import java.io.IOException; public class ExcelExporter { public static void main(String[] args) { // 创建一个工作簿 Workbook workbook = new XSSFWorkbook(); // 创建一个工作表 Sheet sheet = workbook.createSheet("Sheet1"); // 创建一个行 Row row = sheet.createRow(0); // 创建一个单元格,并设置值为带双引号的字符串 Cell cell = row.createCell(0); cell.setCellValue("Hello, \"World\"!"); // 导出Excel时将双引号替换为" String cellValue = cell.getStringCellValue().replace("\"", """); cell.setCellValue(cellValue); // 将工作簿写入文件 try (FileOutputStream outputStream = new FileOutputStream("output.xlsx")) { workbook.write(outputStream); } catch (IOException e) { e.printStackTrace(); } System.out.println("Excel导出成功!"); } } ``` 在上述代码中,我们使用了 Apache POI 库来操作 Excel 文件。首先创建一个工作簿,然后创建一个工作表和行,接着创建一个单元格,并设置它的值为带双引号的字符串。然后,使用 `replace` 方法将双引号替换为 `"`,最后将工作簿写入文件中。 请注意,为了运行此代码,您需要在项目中添加 Apache POI 的相关依赖。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值