# OpenSSL: Can't open openssl.cnf for reading / error loading config file

**Code:** `openssl.cnf` · **Category:** SSL / TLS · **Seen on:** OpenSSL, Windows, Linux

OpenSSL can't find or parse its configuration file, so `req`, `ca` or `x509` commands abort.

## Meaning

Set `OPENSSL_CONF` to the right file (`export OPENSSL_CONF=/etc/ssl/openssl.cnf`, on Windows a path to `openssl.cfg`), or pass `-config file.cnf`. Check for BOM/CRLF in custom configs and for missing sections referenced by `-extensions`.

## Common causes

- OPENSSL_CONF unset/wrong (Windows installs)
- Config path with spaces/backslashes
- Custom config has a syntax error
- Section name referenced but missing
- File permissions

## Quick fix

1. `export OPENSSL_CONF=/etc/ssl/openssl.cnf`
2. Use `-config` explicitly
3. Validate the section names

## Detailed fix by platform

### Shell

1. 

```bash
openssl version -d
export OPENSSL_CONF=/etc/ssl/openssl.cnf
openssl req -new -config my.cnf -key key.pem -out req.csr
```


## How to diagnose

1. **Path** — Exists?
2. **Env var** — Set?
3. **Sections** — Defined?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ssl/openssl-config-file-not-found-openssl-cnf)
