Skip to content

Instantly share code, notes, and snippets.

@joostd
Created April 14, 2020 17:37
Show Gist options
  • Save joostd/d2af94977b2bb53455b9146fbf2fb721 to your computer and use it in GitHub Desktop.
Save joostd/d2af94977b2bb53455b9146fbf2fb721 to your computer and use it in GitHub Desktop.
Sectigo REST API example
{
"orgId": 12345,
"externalRequester": $email,
"csr": $csr,
"certType": 423,
"comments": "enroll via API",
"term": 365
}
Accept: application/json
Content-Type: application/json;charset=utf-8
customerUri: youruri
login: youraccountname
password: yourpasswordorapikey
[email protected]
CN=www.example.edu
ssl-types.json:
curl -s https://cert-manager.com/api/ssl/v1/types -H @headers > ssl-types.json
key.pem:
openssl genrsa -out key.pem 2048
csr.pem: key.pem
openssl req -new -key key.pem -out csr.pem -subj "/CN=${CN}"
enroll.json: csr.pem enroll-template.jq
jq -n --rawfile csr csr.pem --arg email "${EMAIL}" -f enroll-template.jq > enroll.json
test: enroll.json
jq -r .csr enroll.json | openssl req -noout -subject
enroll: orderNumber.json
orderNumber.json: enroll.json
curl -sH @headers https://cert-manager.com/api/ssl/v1/enroll -X POST -d @enroll.json > orderNumber.json
cert.pem: orderNumber.json
jq -r .sslId orderNumber.json | xargs -IN curl -sH @headers https://cert-manager.com/api/ssl/v1/collect/N/pem > cert.pem
export.p12: cert.pem key.pem
openssl pkcs12 -export -inkey key.pem -out export.p12 -in cert.pem
clean:
-rm ssl-types.json csr.pem enroll.json cert.pem orderNumber.json
realclean: clean
-rm key.pem export.p12
@joostd
Copy link
Author

joostd commented Apr 21, 2020

The script requires jq for handling JSON, see https://github.com/stedolan/jq/wiki/Installation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment