Failed to Verify the Certificate When Compiling TensorFlow 1.15.5
Symptom
When running the TensorFlow 1.15.5 compilation command, a message is displayed stating "unable to find valid certification path to requested target":

Key Process and Cause Analysis
Key error information: The valid certificate path of the requested target is not found when downloading the dependency.
1 | PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target |
Conclusion and Solution
- Export the certificate using a browser.
- Import the certificate exported from the browser to the server.
- Upload the certificate to the server.
- Import the certificate.
1keytool -import -alias ca -keystore /usr/lib/jvm/java-11-openjdk-11.0.21.9-1.oe2203sp3.aarch64/lib/security/cacerts -file ca.crt -trustcacerts -storepass changeit -noprompt
- Parameter description:
- -alias: specifies the alias (user-defined).
- -keystore: specifies the storage file, which is stored in the java/lib/security directory. (Replace this directory with the actual one.)
- -file: specifies the certificate file (absolute path + file name).
- -storepass: specifies the storage password. It is changeit by default. This password is required when you query or delete configurations.
- -trustcacerts: adds the trusted CA certificate to the keystore.
- -noprompt (optional): disables the prompt message.
- The default password of the cacerts certificate store is changeit. (If the password has been changed, use the new password.)
- Parameter description:
- Check whether the certificate is successfully imported.
1keytool -list -storepass changeit -keystore /usr/lib/jvm/java-11-openjdk-11.0.21.9-1.oe2203sp3.aarch64/lib/security/cacerts | grep -w ca

If the alias exists in the command output, the certificate is successfully imported.
To delete the certificate, run the following command:
1keytool -delete -storepass changeit -keystore /usr/lib/jvm/java-11-openjdk-11.0.21.9-1.oe2203sp3.aarch64/lib/security/cacerts -alias ca
- Restart the device.
reboot
- After the device is restarted, reconfigure the TensorFlow compilation options.
- Configure a network proxy. See Configuring a Network Proxy.
- Configure the pip repository.
1 2
pip config set global.index-url https://mirrors.huaweicloud.com/repository/pypi/simple pip config set global.trusted-host mirrors.huaweicloud.com
- Add the Bazel information to the environment variables.
1export PATH=/path/to/bazel/bazel-0.26.1/output:$PATH
- Add the Python information to the environment variables.
1 2
export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH export PATH=/usr/local/python3.7.5/bin:$PATH
- Recompile TensorFlow.
1bazel build --config=v1 --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" //tensorflow/tools/pip_package:build_pip_package
Parent topic: Troubleshooting
