Building from Source java.io.IOException PKIX path building failed
@SteefR,
Have you tried the above query after trying the **bazel clean --expunge** command. Could you try once and try repeating the above steps. And also make sure you follow the steps mentioned [here](https://www.tensorflow.org/install/source).

Thank you for the details and usually users get this error `PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested` target due to the system firewall. The system firewall restricts the application to connect to external systems. The firewall requires a valid certificate to allow access to the external systems.

Could you please confirm, whether you're installing [Bazel](https://bazel.build/install) normally or via Bazelisk because [Bazelisk](https://github.com/bazelbuild/bazelisk) is an easy way to install Bazel and automatically downloads the correct Bazel version for TensorFlow and if you're using Bazelisk then please download manually and please follow below steps :

wget https://github.com/bazelbuild/bazelisk/releases/download/v1.16.0/bazelisk-darwin-arm64 (If you get any error with respect to certificate then you can use this command wget --no-check-certificate https://github.com/bazelbuild/bazelisk/releases/download/v1.16.0/bazelisk-darwin-arm64

```
chmod +x bazelisk-darwin-arm64

sudo mv bazelisk-darwin-arm64 /usr/local/bin/bazel
```

If you have already done the above steps and installed Bazel correctly then please execute below steps to see the Bazel or Bazelisk location and if possible please help me with those details

```
1. whereis bazel
2. whereis bazelisk
```

Also Could you please have a look at  https://bazel.build/install/compile-source#bootstrap-unix.
 and comment out 'for' statement and rebuild a binary version of bazel:
https://github.com/bazelbuild/bazel/blob/master/src/main/cpp/blaze.cc#L1015
Then use this to build tensorflow. Thank you! The way I fixed it was removing my bazel installation, and installing using apt, and adding

startup --host_jvm_args=-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts \
            --host_jvm_args=-Djavax.net.ssl.trustStorePassword=changeit

to ~/.bazelrc @SteefR,
Glad the issue was fixed. Could you please feel free to move this issue to closed status. Thank you! Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/62894">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/62894">No</a>

### Issue type

Build/Install

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

source

### TensorFlow version

tf 2.16

### Custom code

No

### OS platform and distribution

Linux Ubuntu 22.04

### Mobile device

_No response_

### Python version

3.11

### Bazel version

6.5.0

### GCC/compiler version

Clang 14.0

### CUDA/cuDNN version

-

### GPU model and memory

-

### Current behavior?

I am trying to install Tensorflow from source on Linux Ubuntu 22.04 following the guide, and I managed to get to configure the bazel build just fine (I am building without gpu support).
When trying to build it can download all packages except when trying to download from [https://golang.org/dl/?mode=json&include=all, https://golang.google.cn/dl/?mode=json&include=all]
i get the error java.io.IOException: Error downloading [https://golang.org/dl/?mode=json&include=all, https://golang.google.cn/dl/?mode=json&include=all] to /home/name/.cache/bazel/_bazel_name/53019e683ff9cb9992223629eccf493b/external/go_sdk/versions.json: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I tried to install the certification manually and found some places to do it, but still no luck. Can someone help me?

### Standalone code to reproduce the issue

```shell
bazel build //tensorflow/tools/pip_package:build_pip_package
```


### Relevant log output

```shell
bazel build //tensorflow/tools/pip_package:build_pip_package
INFO: Reading 'startup' options from /home/name/Documents/tensorflow_git/.bazelrc: --windows_enable_symlinks
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=165
INFO: Reading rc options for 'build' from /home/name/Documents/tensorflow_git/.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
INFO: Reading rc options for 'build' from /home/name/Documents/tensorflow_git/.bazelrc:
  'build' options: --define framework_shared_object=true --define tsl_protobuf_header_only=true --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone -c opt --announce_rc --define=grpc_no_ares=true --noincompatible_remove_legacy_whole_archive --features=-force_no_whole_archive --enable_platform_specific_config --define=with_xla_support=true --config=short_logs --config=v2 --define=no_aws_support=true --define=no_hdfs_support=true --experimental_cc_shared_library --experimental_link_static_libraries_once=false --incompatible_enforce_config_setting_visibility
INFO: Reading rc options for 'build' from /home/name/Documents/tensorflow_git/.tf_configure.bazelrc:
  'build' options: --action_env PYTHON_BIN_PATH=/usr/bin/python3 --action_env PYTHON_LIB_PATH=/usr/lib/python3/dist-packages --python_path=/usr/bin/python3 --action_env CLANG_COMPILER_PATH=/usr/lib/llvm-14/bin/clang --repo_env=CC=/usr/lib/llvm-14/bin/clang --repo_env=BAZEL_COMPILER=/usr/lib/llvm-14/bin/clang
INFO: Found applicable config definition build:short_logs in file /home/name/Documents/tensorflow_git/.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:v2 in file /home/name/Documents/tensorflow_git/.bazelrc: --define=tf_api_version=2 --action_env=TF2_BEHAVIOR=1
INFO: Found applicable config definition build:linux in file /home/name/Documents/tensorflow_git/.bazelrc: --host_copt=-w --copt=-Wno-all --copt=-Wno-extra --copt=-Wno-deprecated --copt=-Wno-deprecated-declarations --copt=-Wno-ignored-attributes --copt=-Wno-array-bounds --copt=-Wunused-result --copt=-Werror=unused-result --copt=-Wswitch --copt=-Werror=switch --copt=-Wno-error=unused-but-set-variable --define=PREFIX=/usr --define=LIBDIR=$(PREFIX)/lib --define=INCLUDEDIR=$(PREFIX)/include --define=PROTOBUF_INCLUDE_PATH=$(PREFIX)/include --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 --config=dynamic_kernels --experimental_guard_against_concurrent_changes
INFO: Found applicable config definition build:dynamic_kernels in file /home/name/Documents/tensorflow_git/.bazelrc: --define=dynamic_loaded_kernels=true --copt=-DAUTOLOAD_DYNAMIC_KERNELS
INFO: Build options --action_env and --python_path have changed, discarding analysis cache.
INFO: Repository go_sdk instantiated at:
  /home/name/Documents/tensorflow_git/WORKSPACE:92:14: in <toplevel>
  /home/name/Documents/tensorflow_git/tensorflow/workspace0.bzl:135:20: in workspace
  /home/name/.cache/bazel/_bazel_name/53019e683ff9cb9992223629eccf493b/external/com_github_grpc_grpc/bazel/grpc_extra_deps.bzl:36:27: in grpc_extra_deps
  /home/name/.cache/bazel/_bazel_name/53019e683ff9cb9992223629eccf493b/external/io_bazel_rules_go/go/private/sdk.bzl:431:28: in go_register_toolchains
  /home/name/.cache/bazel/_bazel_name/53019e683ff9cb9992223629eccf493b/external/io_bazel_rules_go/go/private/sdk.bzl:130:21: in go_download_sdk
Repository rule _go_download_sdk defined at:
  /home/name/.cache/bazel/_bazel_name/53019e683ff9cb9992223629eccf493b/external/io_bazel_rules_go/go/private/sdk.bzl:117:35: in <toplevel>
WARNING: Download from https://golang.org/dl/?mode=json&include=all failed: class javax.net.ssl.SSLHandshakeException PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
WARNING: Download from https://golang.google.cn/dl/?mode=json&include=all failed: class javax.net.ssl.SSLHandshakeException PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
ERROR: An error occurred during the fetch of repository 'go_sdk':
   Traceback (most recent call last):
        File "/home/name/.cache/bazel/_bazel_name/53019e683ff9cb9992223629eccf493b/external/io_bazel_rules_go/go/private/sdk.bzl", line 71, column 21, in _go_download_sdk_impl
                ctx.download(
Error in download: java.io.IOException: Error downloading [https://golang.org/dl/?mode=json&include=all, https://golang.google.cn/dl/?mode=json&include=all] to /home/name/.cache/bazel/_bazel_name/53019e683ff9cb9992223629eccf493b/external/go_sdk/versions.json: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
ERROR: /home/name/Documents/tensorflow_git/WORKSPACE:92:14: fetching _go_download_sdk rule //external:go_sdk: Traceback (most recent call last):
        File "/home/name/.cache/bazel/_bazel_name/53019e683ff9cb9992223629eccf493b/external/io_bazel_rules_go/go/private/sdk.bzl", line 71, column 21, in _go_download_sdk_impl
                ctx.download(
Error in download: java.io.IOException: Error downloading [https://golang.org/dl/?mode=json&include=all, https://golang.google.cn/dl/?mode=json&include=all] to /home/name/.cache/bazel/_bazel_name/53019e683ff9cb9992223629eccf493b/external/go_sdk/versions.json: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted: java.io.IOException: Error downloading [https://golang.org/dl/?mode=json&include=all, https://golang.google.cn/dl/?mode=json&include=all] to /home/name/.cache/bazel/_bazel_name/53019e683ff9cb9992223629eccf493b/external/go_sdk/versions.json: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
INFO: Elapsed time: 27.591s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (323 packages loaded, 7971 targets configured)
```
