forked from TrueCloudLab/certificates
Make meta
object optional in ACME directory response
Harware appliances from Kemp seem to validate the contents of the `meta` object, even if none of the properties in the `meta` object is set. According to the RFC, the `meta` object, as well as its properties are optional, so technically this should be fixed by the manufacturer. This commit is to see if we validation of the `meta` object is skipped if it's not available in the response.
This commit is contained in:
parent
7b45968198
commit
c9793561ff
2 changed files with 11 additions and 6 deletions
|
@ -205,7 +205,7 @@ type Directory struct {
|
|||
NewOrder string `json:"newOrder"`
|
||||
RevokeCert string `json:"revokeCert"`
|
||||
KeyChange string `json:"keyChange"`
|
||||
Meta Meta `json:"meta"`
|
||||
Meta *Meta `json:"meta,omitempty"`
|
||||
}
|
||||
|
||||
// ToLog enables response logging for the Directory type.
|
||||
|
@ -228,16 +228,21 @@ func GetDirectory(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
linker := acme.MustLinkerFromContext(ctx)
|
||||
render.JSON(w, &Directory{
|
||||
directory := &Directory{
|
||||
NewNonce: linker.GetLink(ctx, acme.NewNonceLinkType),
|
||||
NewAccount: linker.GetLink(ctx, acme.NewAccountLinkType),
|
||||
NewOrder: linker.GetLink(ctx, acme.NewOrderLinkType),
|
||||
RevokeCert: linker.GetLink(ctx, acme.RevokeCertLinkType),
|
||||
KeyChange: linker.GetLink(ctx, acme.KeyChangeLinkType),
|
||||
Meta: Meta{
|
||||
}
|
||||
// Only add the ACME `meta` object when one (or more) of its
|
||||
// properties is set.
|
||||
if acmeProv.RequireEAB {
|
||||
directory.Meta = &Meta{
|
||||
ExternalAccountRequired: acmeProv.RequireEAB,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
render.JSON(w, directory)
|
||||
}
|
||||
|
||||
// NotImplemented returns a 501 and is generally a placeholder for functionality which
|
||||
|
|
|
@ -129,7 +129,7 @@ func TestHandler_GetDirectory(t *testing.T) {
|
|||
NewOrder: fmt.Sprintf("%s/acme/%s/new-order", baseURL.String(), provName),
|
||||
RevokeCert: fmt.Sprintf("%s/acme/%s/revoke-cert", baseURL.String(), provName),
|
||||
KeyChange: fmt.Sprintf("%s/acme/%s/key-change", baseURL.String(), provName),
|
||||
Meta: Meta{
|
||||
Meta: &Meta{
|
||||
ExternalAccountRequired: true,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue