Deleting a key

Updated: May 17, 2017

SmartKey provides multiple interfaces to application developers. For C/C++ programmers, SmartKey provides a PKCS#11 interface through a library. For Java programmers, SmartKey can be accessed through the JCE interface. SmartKey can also be accessed through its RESTful interface, documented at http://support.smartkey.io/api/index.html

We provide examples for using SmartKey in 3 languages – a C++ program using the PKCS#11 interface, a Java program using the JCE interface, and a Python program using the REST interface.

Download the code to initialize and login. The example programs can be downloaded in full at http://support.smartkey.io/smartkey/resources.html


CK_RV delete_key(CK_FUNCTION_LIST_PTR p11, CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hKey) {
	return p11->C_DestroyObject(hSession, hKey);
}


private static boolean delete_key(KeyStore ks, String alias) {
        try {
            ks.deleteEntry(alias);
            return true;
        } catch (Exception e) {
            System.out.println("Can't delete key " + alias + ": " + e);
            return false;
        }
    }

def delete_key(bearer_token, kid):
    res = requests.request(method='DELETE',
                           url="https://www.smartkey.io/crypto/v1/keys/" + kid,
                           headers={'Authorization' : 'Bearer ' + bearer_token})
    if res.status_code != requests.codes.no_content:
        print "Can't delete key: " + str(res.status_code)
    else:
        print "Deleted Key"