tech5usa / TLSential

A server for providing short-lived TLS certificates to all services within a firewall restricted network.
GNU General Public License v3.0
15 stars 2 forks source link

Allow client to specify RenewAt when creating certs. If no value is s… #43

Closed debus closed 4 years ago

debus commented 4 years ago

…upplied then default to the default renewal value

This PR addresses the following issues:

https://github.com/ImageWare/TLSential/issues/24

Context

Client has no way of specifying the number of days before expiration to renew a certificate.

Approach

Allow client to specify RenewAt in their POST /api/certificate request. This value must be an integer. If the value is not supplied then it defaults to the value of model.DefaultRenewAt

Testing

Started the server and ran the following curl commands with the output below Note the RenewAt values

curl -vvv -X POST localhost:8080/api/certificate -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" --data '{"Domains":["notexample.com"],"Email":"dmxorcist@gmail.com"}'
{"ID":"1bKqjwwdYxCPBgFWiqiwMzNPhcM","Secret":"XjZsJiSTfcjstuq60zLHyQ","CommonName":"notexample.com","Domains":["notexample.com"],"CertURL":"","CertStableURL":"","Expiry":"0001-01-01T00:00:00Z","RenewAt":30,"Issued":false,"LastError":"","ACMEEmail":"dmxorcist@gmail.com"}
curl -vvv -X POST localhost:8080/api/certificate -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" --data '{"Domains":["notexample.com"],"Email":"dmxorcist@gmail.com","RenewAt":10}' 
{"ID":"1bKqdIrWsGI3UVcVP04fzKgtdV0","Secret":"BN9JMixKp1m1gbN1N-p9hg","CommonName":"notexample.com","Domains":["notexample.com"],"CertURL":"","CertStableURL":"","Expiry":"0001-01-01T00:00:00Z","RenewAt":10,"Issued":false,"LastError":"","ACMEEmail":"dmxorcist@gmail.com"}
todo[bot] commented 4 years ago

Should probably decide valid range for client supplied RenewAt value

https://github.com/ImageWare/TLSential/blob/30881dc6ba9c1ac9bd97e48f39aa1b5b0973dec1/api/certificate.go#L244-L249


This comment was generated by todo based on a TODO comment in 30881dc6ba9c1ac9bd97e48f39aa1b5b0973dec1 in #43. cc @ImageWare.