Source: https://swgbar.com/en/guides/fix-java-maven-gradle-intellij-android-studio-pkix-mac/
Language: en

# Fix Java, Maven, Gradle, IntelliJ & Android Studio 'PKIX path building failed' on Mac

Fix PKIX path building failed: unable to find valid certification path to requested target in Java, Maven, Gradle, IntelliJ IDEA, and Android Studio behind Zscaler, Cloudflare WARP, or Netskope on macOS.

SWG bar · Updated November 24, 2026

On a corporate MacBook behind an SSL-inspecting Secure Web Gateway (Zscaler, Cloudflare WARP, Netskope, Cisco Umbrella, Palo Alto, or Fortinet), **Java, Maven, Gradle, IntelliJ IDEA, Android Studio, and Eclipse** routinely fail dependency downloads and SDK syncs with:

```
javax.net.ssl.SSLHandshakeException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target
```

This happens because the JVM reads its own isolated `cacerts` truststore instead of macOS System Keychain—and a typical developer Mac has **three to five separate JVMs** (Homebrew OpenJDK, SDKMAN/Temurin, IntelliJ’s bundled JetBrains Runtime, and Android Studio’s bundled JBR). Paste your raw stack trace into our free [SWG & SSL Error Decoder](<https://swgbar.com/en/tools/tls-error-decoder/>) or follow the exact macOS fixes below.

## 1\. Export your corporate SWG Root CA PEM on macOS

First verify which gateway is re-signing traffic to `repo.maven.apache.org` or `services.gradle.org` via **SWG bar → Certificates** or Terminal:

```
openssl s_client -connect repo.maven.apache.org:443 -servername repo.maven.apache.org </dev/null 2>/dev/null | openssl x509 -noout -issuer
```

Then export the matching root certificate from macOS System Keychain into `~/.certs/corporate-swg-root.pem`:

```
mkdir -p "$HOME/.certs"
# Replace "Zscaler" with Cloudflare, goskope, Cisco Umbrella, Fortinet, or your corporate CA name
security find-certificate -c "Zscaler" -p /Library/Keychains/System.keychain > "$HOME/.certs/corporate-swg-root.pem"
```

## 2\. Fastest fix: make Java, Maven & Gradle read macOS Keychain directly

On macOS, modern OpenJDK builds include Apple’s `KeychainStore` provider, which lets the JVM trust your MDM-installed SWG root CA without manually modifying `cacerts`:

*   **Gradle (persistent for all projects)** — add to `~/.gradle/gradle.properties`:
    
    ```
    systemProp.javax.net.ssl.trustStoreType=KeychainStore
    ```
    
    Then stop any running daemon so Gradle reloads TLS settings:
    
    ```
    ./gradlew --stop
    ```
    
*   **Maven** — add to `~/.zshrc`:
    
    ```
    export MAVEN_OPTS="-Djavax.net.ssl.trustStoreType=KeychainStore"
    ```
    
*   **Standalone Java CLI**:
    
    ```
    java -Djavax.net.ssl.trustStoreType=KeychainStore -jar app.jar
    ```
    

_(Note: Some third-party JDK builds or Gradle plugins explicitly open `cacerts` or ignore `KeychainStore`. If you still see `PKIX path building failed`, import the root CA into each active `cacerts` store below.)_

## 3\. Import the SWG Root CA into `cacerts` (JDK, IntelliJ & Android Studio)

Check which JDK is active in your shell (`echo "$JAVA_HOME"`), then import the PEM using `keytool` (default `cacerts` password is `changeit`):

```
# Active JAVA_HOME (JDK 9+)
sudo "$JAVA_HOME/bin/keytool" -importcert -cacerts \
  -storepass changeit -noprompt \
  -alias corporate-swg-root \
  -file "$HOME/.certs/corporate-swg-root.pem"
```

### Critical macOS `cacerts` paths that developers miss

Fixing only `$JAVA_HOME` often leaves IDE syncs broken because JetBrains IDEs and Android Studio run on their own bundled **JetBrains Runtime (`jbr`)**—and **Android Studio 2024+ renamed `jre` to `jbr`**:

| Tool on macOS | Default `cacerts` path | Command / Note |
| --- | --- | --- |
| **Homebrew OpenJDK (Apple Silicon)** | `/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/security/cacerts` | Re-run after `brew upgrade openjdk` |
| **Android Studio (2024+)** | `/Applications/Android Studio.app/Contents/jbr/Contents/Home/lib/security/cacerts` | Older versions used `Contents/jre/...` |
| **IntelliJ IDEA** | `/Applications/IntelliJ IDEA.app/Contents/jbr/Contents/Home/lib/security/cacerts` | Also check **Settings → Tools → Server Certificates** and add `~/.certs/corporate-swg-root.pem` |
| **SDKMAN / Downloaded JDKs** | `~/.sdkman/candidates/java/current/lib/security/cacerts` or `~/Library/Java/JavaVirtualMachines/*/Contents/Home/lib/security/cacerts` | Check Project SDK in **File → Project Structure → SDKs** |
| **Eclipse** | Bundled JustJ JRE inside `/Applications/Eclipse.app/Contents/Eclipse/plugins/.../lib/security/cacerts` | Or point `eclipse.ini` `-vm` to your configured JDK |

Example command for **Android Studio on macOS**:

```
sudo "/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/keytool" \
  -importcert -noprompt -storepass changeit \
  -keystore "/Applications/Android Studio.app/Contents/jbr/Contents/Home/lib/security/cacerts" \
  -alias corporate-swg-root \
  -file "$HOME/.certs/corporate-swg-root.pem"
```

Verify the import and restart the IDE + Gradle daemons:

```
"$JAVA_HOME/bin/keytool" -list -cacerts -storepass changeit -alias corporate-swg-root
./gradlew --stop
```

## 4\. Why `cacerts` breaks again after updates—and how to bypass per domain

Every macOS **Android Studio update, IntelliJ Toolbox upgrade, or `brew upgrade openjdk`** replaces the bundled `cacerts` file and wipes out your custom `keytool` import.

If your company policy permits per-domain SWG bypass for developer registries, [SWG bar](<https://swgbar.com/en/install/>) detects exactly which artifact hosts (`repo.maven.apache.org`, `services.gradle.org`, `plugins.gradle.org`, `dl.google.com`) are being decrypted and lets you bypass them per domain in one click—without touching a single `cacerts` file or lowering TLS security:

```
swgbar probe repo.maven.apache.org
swgbar bypass enable repo.maven.apache.org
swgbar bypass enable services.gradle.org
swgbar bypass enable dl.google.com
```

Need to fix other macOS developer tools too? See [How to bypass SWG on a Mac](<https://swgbar.com/en/guides/how-to-bypass-swg/>), [Fix Git & npm SSL certificate errors](<https://swgbar.com/en/guides/fix-git-npm-unable-to-get-local-issuer-certificate-mac/>), and [Fix Python & Docker SSL errors on Mac](<https://swgbar.com/en/guides/fix-python-docker-certificate-verify-failed-x509-mac/>).

macOS 14+ · Apple Silicon

## Stop guessing which domains your company SWG decrypts.

SWG bar checks HTTPS inspection right from your Mac’s menu bar and lets you bypass broken domains in one click—while keeping corporate VPN and SSO running.

[Start a 14-day trial for $0](<https://swgbar.com/releases/2.4.12/SWGBar-macOS-arm64.pkg>) [Decode a TLS error](<https://swgbar.com/en/tools/tls-error-decoder/>) [Free Chrome extension](<https://chromewebstore.google.com/detail/bidclnlfneemkkdeanlcbpjfdalelmbf>)

## Keep reading

*   [How to Bypass SWG on a Mac (Zscaler, Cloudflare, Netskope — 1-Click & CLI)](<https://swgbar.com/en/guides/how-to-bypass-swg/>)
*   [How to Bypass SSL Inspection on a Mac (Corporate SWG & Per-Domain Fix)](<https://swgbar.com/en/guides/bypass-ssl-inspection-mac/>)
*   [How to Bypass HTTPS & TLS Inspection on macOS (Break-and-Inspect Guide)](<https://swgbar.com/en/guides/bypass-https-tls-inspection-mac/>)
*   [How to Bypass Corporate Proxy & SWG SSL Inspection on a Mac](<https://swgbar.com/en/guides/bypass-corporate-proxy-ssl-inspection-mac/>)
*   [How to Check if Your Mac Is Intercepted by an SWG (Zscaler, Netskope & SSL Inspection)](<https://swgbar.com/en/guides/detect-https-inspection/>)
*   [How to Check if Your Employer or Work Mac Is Intercepting HTTPS (SSL Inspection)](<https://swgbar.com/en/guides/check-if-work-mac-intercepting-https/>)
*   [Can My Employer See My Browsing History, Incognito & Personal Accounts on a Work Mac?](<https://swgbar.com/en/guides/can-employer-see-browsing-history-incognito-work-mac/>)
*   [SSL Inspection Checker for Mac: Menu Bar Tool to Detect HTTPS Interception](<https://swgbar.com/en/guides/ssl-inspection-checker-mac/>)
*   [Zscaler SSL Inspection on Mac: How to Check & Bypass per Domain](<https://swgbar.com/en/guides/zscaler-ssl-inspection-bypass-mac/>)
*   [How to Turn Off or Bypass Zscaler on a Mac (When Tamper Protection Locks It)](<https://swgbar.com/en/guides/disable-turn-off-zscaler-on-mac/>)
*   [Cloudflare WARP & Zero Trust TLS Inspection on Mac: Detect & Bypass](<https://swgbar.com/en/guides/cloudflare-warp-tls-inspection-mac/>)
*   [Netskope SSL Inspection on Mac: Check Decryption & Bypass per Domain](<https://swgbar.com/en/guides/netskope-ssl-inspection-bypass-mac/>)
*   [Cisco Umbrella SSL Inspection on Mac: Check Decryption & Bypass per Domain](<https://swgbar.com/en/guides/cisco-umbrella-ssl-inspection-bypass-mac/>)
*   [Palo Alto GlobalProtect & Prisma Access SSL Decryption on Mac: Check & Bypass](<https://swgbar.com/en/guides/palo-alto-globalprotect-prisma-ssl-decryption-mac/>)
*   [Fortinet FortiClient & FortiGate (Fortinet\_CA\_SSL) Inspection on Mac: Check & Bypass](<https://swgbar.com/en/guides/fortinet-forticlient-ssl-inspection-bypass-mac/>)
*   [Fix Git & npm 'unable to get local issuer certificate' / SELF\_SIGNED\_CERT\_IN\_CHAIN on Mac](<https://swgbar.com/en/guides/fix-git-npm-unable-to-get-local-issuer-certificate-mac/>)
*   [Fix Python 'CERTIFICATE\_VERIFY\_FAILED' & Docker 'x509: certificate signed by unknown authority' on Mac](<https://swgbar.com/en/guides/fix-python-docker-certificate-verify-failed-x509-mac/>)
*   [Fix GitHub Copilot, OpenAI Codex & Gemini CLI SSL Certificate Errors on Mac (Zscaler / SWG)](<https://swgbar.com/en/guides/fix-codex-copilot-gemini-cli-ssl-certificate-error-mac/>)
*   [Fix AWS CLI & Boto3 'SSL validation failed' Certificate Errors on Mac](<https://swgbar.com/en/guides/fix-aws-cli-boto3-ssl-validation-failed-mac/>)
*   [Fix Google Cloud (gcloud) & Azure CLI (az login) SSL Certificate Errors on Mac](<https://swgbar.com/en/guides/fix-gcloud-azure-cli-ssl-certificate-verify-failed-mac/>)
*   [Fix Firefox 'SEC\_ERROR\_UNKNOWN\_ISSUER' Behind Zscaler & Corporate SWGs on Mac](<https://swgbar.com/en/guides/fix-firefox-sec-error-unknown-issuer-mac/>)
*   [Confirmed vs. Suspected HTTPS inspection in SWG bar](<https://swgbar.com/en/guides/confirmed-vs-suspected-https-inspection/>)
*   [Inspect MITM root certificates & issuers in SWG bar](<https://swgbar.com/en/guides/inspect-mitm-root-certificates-macos/>)
*   [Enterprise SWG & MDM HTTPS inspection on a Mac](<https://swgbar.com/en/guides/enterprise-swg-https-inspection-macos/>)
*   [SWG bypass vs. TLS inspection exception (break and inspect)](<https://swgbar.com/en/guides/swg-bypass-vs-tls-exception/>)
*   [Bypass SWG for multi-domain web apps, SSO, CDNs & APIs on Mac](<https://swgbar.com/en/guides/multi-domain-sso-api-cdn-swg-bypass/>)
*   [Fix SWG bypass Recovering, Paused & connection errors on Mac](<https://swgbar.com/en/guides/troubleshoot-swg-bypass-recovering-paused-macos/>)
*   [macOS VPN virtual interfaces vs. SWG HTTPS inspection](<https://swgbar.com/en/guides/macos-vpn-virtual-interface-vs-swg-inspection/>)
*   [Why certificate-pinned apps & mTLS break under SWG inspection](<https://swgbar.com/en/guides/certificate-pinning-mtls-swg-inspection-macos/>)
*   [Fix SWG TLS & SSL certificate errors in CLI and AI tools on a Mac](<https://swgbar.com/en/guides/swg-tls-certificate-errors-macos/>)
*   [Homebrew, Docker, Python & Node.js CA trust behind an SWG on Mac](<https://swgbar.com/en/guides/homebrew-docker-python-node-ca-trust-swg-macos/>)
*   [Fix Claude Code & Cursor 'unable to get local issuer certificate' on Mac (SWG & MCP)](<https://swgbar.com/en/guides/ai-coding-agents-claude-code-cursor-swg-macos/>)
*   [Verify TLS certificates with openssl & security verify-cert on Mac](<https://swgbar.com/en/guides/verify-tls-certificates-openssl-security-verify-cert-macos/>)
*   [SWG bar permissions, local privacy & TLS probe limits](<https://swgbar.com/en/guides/macos-network-extension-privacy-probe-limits/>)
*   [How SWG bar checks HTTPS inspection](<https://swgbar.com/en/how-it-works/>)
*   [Download & install SWG bar for Mac (macOS 14+)](<https://swgbar.com/en/install/>)
*   [Chrome Extension to Detect SSL & HTTPS Inspection (SWG Bar Companion)](<https://swgbar.com/en/chrome-extension/>)
*   [SWG bar CLI Guide](<https://swgbar.com/en/cli/>)
*   [SWG bar MCP Guide](<https://swgbar.com/en/mcp/>)
*   [SWG bar release information](<https://swgbar.com/en/releases/>)
*   [About SWG bar](<https://swgbar.com/en/about/>)
