For some "well-known" reasons, the Azure China version uses a domestic wosign certificate--and the infamous cnnic has a fight. Apple does not trust the Wosign certificate, which is why the certificate is not trusted when you access www.azure.cn in Mac OS. Similarly, the JDK does not see the goods, which leads to the "PKIX Path building failed" error when calling Azure China API in Java.
Because the JDK does not use the Windows operating system's certificate store, Windows is trusted wosign, but still requires the Wosign root certificate to be manually added to the trusted certificate store of the JDK.
To http://www. Wosign. com/root/index.htm Download Wosign root certificate (this domain name unexpectedly is the forbidden word of cnblogs ... )。
Add wosign Root certificate to JDK:
Keytool-keystore C:\Java8\jdk1. 8. 0_92\jre\lib\security\cacerts-importcert-alias wosign-file C:\Users\hunte\Deskto P\ws_ca1_new.cer
Command format:
Keytool-keystore [java_home directory]\jre\lib\security\cacerts-importcert-alias wosign-file [WoSign root certificate file location]
You see a prompt similar to the following to indicate that the root certificate was added successfully.
If an error occurs, check to see if the local Path environment variable contains "%java_home%\bin". In addition, the JDK and JRE are installed as far as possible not to install to the "program Files" directory, this directory of spaces often cause some inexplicable trouble.
After the root certificate has been added successfully, add a line before you need to call the Java code for the Azure China API:
System.setproperty ("Javax.net.ssl.trustStore", "c:\\java8\\jdk1.8.0_92\\jre\\lib\\security\\cacerts");
Note here that the second parameter is consistent with the certificate store location that was written when the root certificate was added earlier, and the directory-delimited backslash in the Windows environment is escaped (\ \).
After the above steps, calling the Azure Chinese version of the API in Java will work as expected.
Add wosign root certificate to JDK