# SSL CA cert error on MacOS

**URL:** https://discourse.nixos.org/t/ssl-ca-cert-error-on-macos/31171
**Category:** Help
**Created:** [August 1, 2023, 2:52pm UTC](https://discourse.nixos.org/t/ssl-ca-cert-error-on-macos/31171 "2023-08-01T14:52:46Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![weitzj](https://discourse.nixos.org/user_avatar/discourse.nixos.org/weitzj/32/11350_2.png) [@weitzj](https://discourse.nixos.org/u/weitzj)
#### Post date: [October 17, 2023, 7:07am UTC](https://discourse.nixos.org/t/ssl-ca-cert-error-on-macos/31171/6 "2023-10-17T07:07:05Z")

</div>

In case you might have a custom truststore with self-signed certificates, this is what you can do:

1. Export all trusted certs in one big bundle

```auto
security export -t certs -f pemseq -k /Library/Keychains/System.keychain -o /tmp/certs-system.pem
security export -t certs -f pemseq -k /System/Library/Keychains/SystemRootCertificates.keychain -o /tmp/certs-root.pem
cat /tmp/certs-root.pem /tmp/certs-system.pem > /tmp/ca_cert.pem

```

1. Copy bundle to /etc/nix/

`sudo mv /tmp/ca_cert.pem /etc/nix/`

1. Edit launchctl plist of nix-daemon

`sudo vi /Library/LaunchDaemons/org.nixos.nix-daemon.plist`

1. Ensure the **EnvironmentVariables** key is present:

```auto
    <key>EnvironmentVariables</key>
    <dict>
      <key>NIX_SSL_CERT_FILE</key>
      <string>/etc/nix/ca_cert.pem</string>
      <key>SSL_CERT_FILE</key>
      <string>/etc/nix/ca_cert.pem</string>
      <key>REQUEST_CA_BUNDLE</key>
      <string>/etc/nix/ca_cert.pem</string>
    </dict>
    <key>ProgramArguments</key>
    <array>

```

1. Reload nix-daemon service

```auto
sudo launchctl unload /Libray/LaunchDaemons/org.nixos.nix-daemon.plist
sudo launchctl load /Libray/LaunchDaemons/org.nixos.nix-daemon.plist

```

1. Verify service contains EnvironmentVariables

```auto
sudo launchctl print system/org.nixos.nix-daemon

```

---

_[View the full topic](https://discourse.nixos.org/t/ssl-ca-cert-error-on-macos/31171)._
