The v1 REST API is located at https://certs.it.vt.edu/api/v1.
See the REST API overview for authentication setup and prerequisites.
REST API Client Example
The following Python sample covers authentication and a basic search:
import jwt
import os
import sys
import time
import requests
# Token validity period in hours
# Set to 0 to produce a token that never expires (not recommended)
VALIDITY_PERIOD=12
if len(sys.argv) < 3:
print ("USAGE: ed-service /path/to/private.key")
sys.exit(0)
issuer = sys.argv[1]
key_path = sys.argv[2]
with open(key_path, 'r') as f:
key = f.read()
# Create authentication token that is valid for VALIDITY_PERIOD hours
now = int(time.time())
claims = {}
claims['iss'] = 'uusid={0},ou=services,dc=vt,dc=edu'.format(issuer)
claims['sub'] = 'uusid={0},ou=services,dc=vt,dc=edu'.format(issuer)
claims['iat'] = now
claims['exp'] = now + VALIDITY_PERIOD * 60 * 60
token = jwt.encode(claims, key, algorithm='RS256')
# Base URL to Certificate Manager Web services
base_url = 'https://certs.it.vt.edu/api/v1'
# Set up HTTP headers to pass the authentication token
# MUST pass these headers with all requests
headers = {'Authorization': 'Bearer ' + token.decode("utf-8")}
# Query for certs requested by waconley
response = requests.get(base_url + '/certs?by=username&keyword=waconley', headers=headers)
certs = response.text
print (certs)Certs Resource
Searches support a single criterion at a time using by and keyword parameters.
Supported by values:
cn— common nameusername— requester PIDemail— requester emailserial— certificate serial number
Examples:
- by=cn&keyword=vt.edu
- by=username&keyword=waconley
- by=email&keyword=waconley@vt.edu
- by=serial&keyword=1A2B3C4D5F
# Resource URI: /v1/certs?by=x&keyword=y
[
{
"encoded":"",
"subject":"",
"serial":"",
"status":"",
"notBefore":"",
"notAfter":"",
"request":{
"email":"",
"commonName":"",
"subjectAltNames":[
]
}
}
]