hashicorp / hashicorp/vault-client-go
`max_path_length` value of 0 in `PkiIssuerSignIntermediateRequest` struct should not be omitted
- Dominant language
- Go
- Stars
- 133
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
# Expected Behavior
When signing intermediate certificate with [`client.Secrets.PkiIssuerSignIntermediate`](https://github.com/hashicorp/vault-client-go/blob/main/api_secrets.go#L5017) function with request parameter as:
```go
request := schema.PkiIssuerSignIntermediateRequest{
...
MaxPathLength: 0,
...
}
```
`max_path_length` property is omitted from the request body to the vault API, leading to generated certificate without `pathlength` property:
```
X509v3 Basic Constraints: critical
CA:TRUE, pathlen:0 -> missing part
```
This might be due to `omitempty` setting on `MaxPathLength int32 json:"max_path_length,omitempty"` property in [PkiIssuerSignIntermediateRequest](https://github.com/hashicorp/vault-client-go/blob/main/schema/model_pki_issuer_sign_intermediate_request.go#L38) struct.
# Current Behavior
I think `MaxPathLength: 0` should not be omitted and certificate with `pathlen:0` should be generated.
# Failure Information
v0.4.3
## Steps to Reproduce
Simply try to sign intermediate certificate, or build a variable with `MaxPathLength = 0` of type `PkiIssuerSignIntermediateRequest` and `json.Encode` it. You will notice that json will not contain this value.
# Additional Information
I think this property type should be a pointer (`*int32`). (Or `omitempty` removed completely).
Contributor guide
Research direction
Start with schema/model_pki_issuer_sign_intermediate_request.go and inspect the MaxPathLength JSON field used by client.Secrets.PkiIssuerSignIntermediate. Reproduce the issue by encoding a request with MaxPathLength set to 0, then verify the request includes max_path_length and that the generated certificate has pathlen:0.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100