What does 'unknown field "issuer"' mean?

1. Caddy version (caddy version): v2.5.1

2. How I run Caddy:

/root/caddy run --config /etc/caddy/caddy.json

a. System environment:

os: ubuntu18.04

b. Command:

/root/caddy run --config /etc/caddy/caddy.json

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

the following is the contents of /etc/caddy/caddy.json

{
    "admin": {
        "disabled": true
    },
    "apps": {
        "http": {
            "servers": {
                "srv0": {
                    "listen": [
                        ":1443"
                    ],
                    "logs": {},
                    "routes": [
                        {
                            "handle": [
                                {
                                    "handler": "forward_proxy",
                                    "hide_ip": true,
                                    "hide_via": true,
                                    "auth_user": "myusername",
                                    "auth_pass": "mypassword"
                                }
                            ]
                        },
                        {
                            "match": [
                                {
                                    "host": [
                                        "cd.smt.biz.st"
                                    ]
                                }
                            ],
                            "handle": [
                                {
                                    "handler": "vars",
                                    "root": "/var/www/html"
                                }
                            ],
                            "terminal": true
                        }
                    ],
                    "tls_connection_policies": [
                        {
                            "match": {
                                "sni": [
                                    "cd.smt.biz.st"
                                ]
                            }
                        }
                    ],
                    "experimental_http3": true,
                    "allow_h2c": true
                }
            }
        },
        "tls": {
            "automation": {
                "policies": [
                    {
                        "subjects": [
                            "cd.smt.biz.st"
                        ],
                        "issuer": {
                            "email": "xyz@12.com",
                            "module": "acme"
                        }
                    }
                ]
            }
        }
    }
}

3. The problem I’m having:

i ran command: /root/caddy run --config /etc/caddy/caddy.json

i got the error message as below.

4. Error messages and/or full log output:

2022/07/06 15:36:57.338 INFO using provided configuration {"config_file": "/etc/caddy/caddy.json", "config_adapter": ""}
2022/07/06 15:36:57.341 WARN admin admin endpoint disabled
run: loading initial config: loading new config: loading http app module: provision http: getting tls 
app: loading tls app module: decoding module config: tls: json: unknown field "issuer"

5. What I already tried:

6. Links to relevant resources:

how to fix it?

The name of the field is issuers (plural), and the value is an array: JSON Config Structure - Caddy Documentation

1 Like

HI. MR HOLT:
I CHANGED issuer to issuers in caddy.json, then i ran:

root@racknerd-7b97d8:~# /root/caddy run --config /etc/caddy/caddy.json
2022/07/07 02:52:28.595 INFO    using provided configuration    {"config_file": "/etc/caddy/caddy.json", "config_adapter": ""}
2022/07/07 02:52:28.597 WARN    admin   admin endpoint disabled
run: loading initial config: loading new config: loading http app module: provision http: getting tls app: loading tls app module: decoding module config: tls: json: cannot unmarshal object into Go struct field AutomationPolicy.automation.policies.issuers of type []json.RawMessage
root@racknerd-7b97d8:~#

how to fix ‘cannot unmarshal object into Go struct field’ error?
tks a lot

Don’t forget that part. Look at the JSON structure carefully :wink: Basically, wrap your object in [ ]. There can be more than 1 issuer.

hi. mr holt:
i read JSON Config Structure - Caddy Documentation ,but i don’t understand it. so can u tell me how to modify the caddy.json concretely?

aha. i know how to modify the caddy.json file now:
change the part:

"issuers": {
                            "email": "xyz@12.com",
                            "module": "acme"
                        }

to:

"issuers": [{
                            "email": "xyz@12.com",
                            "module": "acme"
                        }]

but this part:
“auth_user”: “myusername”,
“auth_pass”: “mypassword”
is invalid. so how to set authentication?

This topic was automatically closed after 30 days. New replies are no longer allowed.