{"id":6343,"date":"2016-10-12T16:01:04","date_gmt":"2016-10-12T08:01:04","guid":{"rendered":"http:\/\/rmohan.com\/?p=6343"},"modified":"2016-10-12T16:01:04","modified_gmt":"2016-10-12T08:01:04","slug":"certificate-management-by-using-gsk7cmd-command","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6343","title":{"rendered":"Certificate Management by using gsk7cmd command"},"content":{"rendered":"<h3 class=\"post-title entry-title\">Certificate Management by using gsk7cmd command<\/h3>\n<div class=\"post-header\"><\/div>\n<div id=\"post-body-7590708130679549252\" class=\"post-body entry-content\">\n<div dir=\"ltr\">Command: gsk7cmd<\/p>\n<p>Purpose: gsk7cmd is a command line tool for certificate management.<br \/>\nPrerequisite: set JAVA_HOME varriable.<br \/>\nExample: export JAVA_HOME=\/usr\/IBM\/WebSphere\/AppServer\/java (this depends on your environment)<\/p>\n<p>Parameters for below examples:<\/p>\n<p>keystore Name: testcacerts.jks \/ test.kdb<br \/>\npassword: changeit \/ testit<\/p>\n<p>NOTE:- If you are practicing below examples kindly practice it in the sequence because there might be a dependancy.<\/p>\n<p>Command usage<\/p>\n<p># gsk7cmd -help<\/p>\n<p>Object Action Description<br \/>\n&#8212;&#8212; &#8212;&#8212; &#8212;&#8212;&#8212;&#8211;<br \/>\n-keydb<br \/>\n-changepw Change the password for a key database<br \/>\n-convert Convert the format of a key database<br \/>\n-create Create a key database<br \/>\n-delete Delete a key database<br \/>\n-expiry\u00a0Display password expiry<br \/>\n-list Currently supported types of key database.<br \/>\n-stashpw Stash the password of a key database into a file<\/p>\n<p>-cert<br \/>\n-add Add a CA Certificate<br \/>\n-create Create a self-signed certificate<br \/>\n-delete Delete a certificate<br \/>\n-details Show the details of a specific certificate<br \/>\n-export Export a personal certificate and associated private key\u00a0into a PKCS12 file or a key<br \/>\ndatabase<br \/>\n-extract Extract a certificate from a key database<br \/>\n-getdefault Show the default personal certificate<br \/>\n-import Import a certificate from a key database or a PKCS12 file<br \/>\n-list List certificates in a key database<br \/>\n-listsigners List signer certificates delivered with ikeyman<br \/>\n-modify Modify a certificate (NOTE: the only field that may be modified is the trust field)<br \/>\n-populate Populate with included CA Certificates<br \/>\n-receive Receive a certificate<br \/>\n-rename Rename a certificate<br \/>\n-setdefault Set the default personal certificate<br \/>\n-sign Sign a certificate<\/p>\n<p>-certreq<\/p>\n<p>-create Create a certificate request<br \/>\n-delete Delete a certificate request from a certificate request database<br \/>\n-details Show the details of a specific certificate request<br \/>\n-extract Extract a certificate from a certificate request database<br \/>\n-list List all certificate requests in a certificate request database<br \/>\n-recreate Recreate a certificate request<\/p>\n<p>-seckey<\/p>\n<p>-create Create a secret key<br \/>\n-delete Delete a secret key<br \/>\n-details Show the details of a specific secret key<br \/>\n-export Export secret keys to a file<br \/>\n-import Import secret keys from a file<br \/>\n-list List all secret keys in a key database<br \/>\n-rename Rename a secret key<\/p>\n<p>-version\u00a0\u00a0\u00a0Display iKeyman version information<\/p>\n<p>-help\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Display this help text<\/p>\n<p><strong><u>Keystore Management<\/u>\u00a0 (-keydb)<\/strong><\/p>\n<p><strong><u>Creating keystore by specifying password expiry<\/u><\/strong><\/p>\n<p><strong><em>Example 1<\/em><\/strong><\/p>\n<p>#gsk7cmd -keydb -create -db test.kdb -pw changeit -type kdb -expire 7300<\/p>\n<p>The above command creates a keystore file (test.kdb) of kdb type and keep the password expiry to 7300 days<\/p>\n<p><strong><em>Example 2<\/em><\/strong><\/p>\n<p># gsk7cmd -keydb -expiry -db test.kdb -pw changeit<\/p>\n<p>This will list the password expiry of keystore test.kdb<\/p>\n<p>Output:<\/p>\n<p>Password expiry time: Aug 9, 2032 2:05:51 AM<\/p>\n<p><strong><u>Deleting the keystore<\/u><\/strong><\/p>\n<p><strong><em>Example 3<\/em><\/strong><\/p>\n<p>#gsk7cmd -keydb -delete -db test.kdb -pw changeit<\/p>\n<p>This deletes the keystore file test.kdb<\/p>\n<p><strong><u>Creating a default keystore<\/u><\/strong><\/p>\n<p><em><br \/>\n<\/em><\/div>\n<p><strong><em>Example 4<\/em><\/strong><br \/>\n#gsk7cmd -keydb -create -db testcacerts.jks -pw testit<\/p>\n<p>The above command creates a keystore file with the name testcacerts.jks and the password testit in the current directory<\/p>\n<p><strong>Changing the keystore password<\/strong><\/p>\n<p><strong><em>Example 5<\/em><\/strong><\/p>\n<p>#gsk7cmd -keydb -changepw -db testcacerts.jks -pw testit -new_pw changeit<\/p>\n<p>This changes the password from testit to changeit<\/p>\n<p><strong><u>Certificate Management<\/u> (-cert)<\/strong><\/p>\n<p><strong>Adding certificate to a keystore with out specifying label<\/strong><\/p>\n<p><strong><em>Example 6<\/em><\/strong><\/p>\n<p>#gsk7cmd -cert -add -file test.cer -db testcacerts.jks -pw changeit<\/p>\n<p>This adds the certificate file test.cer in testcacerts.jks keystore, If label is not specified it will generate a label (kindly note the label details in example 7).<\/p>\n<p><strong><em>Example 7<\/em><\/strong><\/p>\n<p>#gsk7cmd -cert -details -label &#8220;cn=TESTCERT, o=IBM, c=us&#8221; -db testcacerts.jks -pw changeit<\/p>\n<p>This command will list the details of certificate with label &#8220;cn=TESTCERT, o=IBM, c=us&#8221; (The certificate which was added in example 6)<\/p>\n<p><strong><em>Output <\/em><\/strong><\/p>\n<p>Label: cn=TESTCERT, o=IBM, c=us<br \/>\nKey Size: 1024<br \/>\nVersion: X509 V3<br \/>\nSerial Number: 12 57 4F 87 1B F8 69 DD<br \/>\nIssued by: CN=TESTCERT, O=IBM, C=US<br \/>\nSubject: CN=TESTCERT, O=IBM, C=US<br \/>\nValid: From: Wednesday, May 12, 2010 2:01:04 AM IST To: Wednesday, May 8, 2030 2:01:04 AM IST<br \/>\nFingerprint: BE:87:67:14:AD:FD:64:B9:CC:08:CF:3E:76:05:2A:DC:BB:EB:DF:69<br \/>\nSignature Algorithm: MD5withRSA (1.2.840.113549.1.1.4)<br \/>\nTrust Status: enabled<\/p>\n<p><strong>Deleting a certificate from the keystore<\/strong><\/p>\n<p><strong><em>Example 8<\/em><\/strong><\/p>\n<p>#gsk7cmd -cert -delete -label &#8220;cn=TESTCERT, o=IBM, c=us&#8221; -db testcacerts.jks -pw changeit<\/p>\n<p>This command deletes the certificate with the label &#8220;cn=TESTCERT, o=IBM, c=us&#8221; (the certificate which was added in example 6)<\/p>\n<p><strong><em>Example 9<\/em><\/strong><\/p>\n<p>#gsk7cmd -cert -details -label &#8220;cn=TESTCERT, o=IBM, c=us&#8221; -db testcacerts.jks -pw changeit<\/p>\n<p>This commands confirms the delete operation in example 8, The below output says the certificate with the label &#8216;cn=TESTCERT, o=IBM, c=us&#8217; does not exists<\/p>\n<p><strong><em>Output<\/em><\/strong><\/p>\n<p>The database doesn&#8217;t contain an entry with label &#8216;cn=TESTCERT, o=IBM, c=us&#8217;.<br \/>\nCheck the label and try again.<\/p>\n<p><strong>Adding certificate to a keystore with the label <\/strong><\/p>\n<p><strong><em>Example 10<\/em><\/strong><\/p>\n<p>#gsk7cmd -cert -add -file test.cer -label &#8220;This is a cert&#8221; -db testcacerts.jks -pw changeit<\/p>\n<p>This adds the certificate &#8216;test.cer&#8217; with the label &#8220;This is a cert&#8221;. (in example 6 we have added the certificate without specifying the label)<\/p>\n<p><strong><em>Example 11<\/em><\/strong><\/p>\n<p>#gsk7cmd -cert -details -label &#8220;This is a cert&#8221; -db testcacerts.jks -pw changeit<\/p>\n<p>This confirms that the certificate test.cer has been added with the label &#8220;This is a cert&#8221;, check the output below\/<\/p>\n<p><strong><em>Output<\/em><\/strong><\/p>\n<p>Label: this is a cert<br \/>\nKey Size: 1024<br \/>\nVersion: X509 V3<br \/>\nSerial Number: 12 57 4F 87 1B F8 69 DD<br \/>\nIssued by: CN=TESTCERT, O=IBM, C=US<br \/>\nSubject: CN=TESTCERT, O=IBM, C=US<br \/>\nValid: From: Wednesday, May 12, 2010 2:01:04 AM IST To: Wednesday, May 8, 2030 2:01:04 AM IST<br \/>\nFingerprint: BE:87:67:14:AD:FD:64:B9:CC:08:CF:3E:76:05:2A:DC:BB:EB:DF:69<br \/>\nSignature Algorithm: MD5withRSA (1.2.840.113549.1.1.4)<br \/>\nTrust Status: enabled<\/p>\n<p><strong>Renaming the label of a certificate<\/strong><\/p>\n<p><strong><em>Example 12<\/em><\/strong><\/p>\n<p>#gsk7cmd -cert -rename -label &#8220;This is a cert&#8221; -new_label &#8220;The_new_label&#8221; -db testcacerts.jks -pw changeit<\/p>\n<p>This renames the lable &#8220;This is a cert&#8221; with new name &#8220;The_new_label&#8221;.<\/p>\n<p><strong><em>Example 13<\/em><\/strong><\/p>\n<p>#gsk7cmd -cert -details -label &#8220;The_new_label&#8221; -db testcacerts.jks -pw changeit<\/p>\n<p>Example 13 and Example 14 confirms example 12,Check the output below.<\/p>\n<p><strong><em>Output<\/em><\/strong><\/p>\n<p>Label: the_new_label<br \/>\nKey Size: 1024<br \/>\nVersion: X509 V3<br \/>\nSerial Number: 12 57 4F 87 1B F8 69 DD<br \/>\nIssued by: CN=TESTCERT, O=IBM, C=US<br \/>\nSubject: CN=TESTCERT, O=IBM, C=US<br \/>\nValid: From: Wednesday, May 12, 2010 2:01:04 AM IST To: Wednesday, May 8, 2030 2:01:04 AM IST<br \/>\nFingerprint: BE:87:67:14:AD:FD:64:B9:CC:08:CF:3E:76:05:2A:DC:BB:EB:DF:69<br \/>\nSignature Algorithm: MD5withRSA (1.2.840.113549.1.1.4)<br \/>\nTrust Status: enabled<\/p>\n<p><strong><em>Example 14<\/em><\/strong><\/p>\n<p>#gsk7cmd -cert -details -label &#8220;This is a cert&#8221; -db testcacerts.jks -pw changeit<\/p>\n<p>Example 14 and Example 13 confirms example 12, because in the output of example 13 testcacerts.jks keystore contains a certificate with the label &#8220;The_new_label&#8221; and the output of example 14 says the testcacerts.jks keystore does not have an with the label &#8220;This is a cert&#8221; (label name before rename).<\/p>\n<p><strong><em>Output<\/em><\/strong><\/p>\n<p>The database doesn&#8217;t contain an entry with label &#8216;This is a cert&#8217;.<br \/>\nCheck the label and try again.<\/p>\n<p><strong>Extracting a certificate from the keyfile<\/strong><\/p>\n<p><strong><em>Example 15<\/em><\/strong><\/p>\n<p>#gsk7cmd -cert -extract -label &#8220;The_new_label&#8221; -target &#8220;this_is_extracted_cert.cer&#8221; -db testcacerts.jks -pw changeit<\/p>\n<p>This will extracrt the certificate with label &#8220;The_new_label&#8221; into a file this_is_extracted_cert.cer, check the below output for file confirmation<\/p>\n<p>#ls this_is_extracted_cert.cer<br \/>\nthis_is_extracted_cert.cer<\/p>\n<p><strong>Creating a self signed certificate<\/strong><\/p>\n<p><strong><em>Example 16<\/em><\/strong><\/p>\n<p>gsk7cmd -cert -create -db testcacerts.jks -pw changeit -label &#8216;New_Self_Signed&#8217; -dn CN=testSELFSIGN,O=ibm,C=in -expire 7300 -size 1024 -x509version 3<\/p>\n<p>This creates a self signed certificate with the label &#8216;New_Self_Signed&#8217;<\/p>\n<p><strong><em>Example 17<\/em><\/strong><\/p>\n<p># gsk7cmd -cert -details -label &#8216;New_Self_Signed&#8217; -db testcacerts.jks -pw changeit<\/p>\n<p>This confirms the self signed certificate creation ,Verify the certificate in the below output<\/p>\n<p><strong><em>Output<\/em><\/strong><\/p>\n<p>Label: new_self_signed<br \/>\nKey Size: 1024<br \/>\nVersion: X509 V3<br \/>\nSerial Number: 50 29 68 22<br \/>\nIssued by: CN=testSELFSIGN, O=ibm, C=in<br \/>\nSubject: CN=testSELFSIGN, O=ibm, C=in<br \/>\nValid: From: Tuesday, August 14, 2012 2:18:34 AM IST To: Monday, August 9, 2032 2:18:34 AM IST<br \/>\nFingerprint: 0C:D5:A0:6A:54:76:6B:3E:D0:3E:2E:42:1C:D0:32:43:66:82:FE:70<br \/>\nSignature Algorithm: SHA1withRSA (1.2.840.113549.1.1.5)<br \/>\nTrust Status: enabled<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Certificate Management by using gsk7cmd command Command: gsk7cmd<\/p>\n<p>Purpose: gsk7cmd is a command line tool for certificate management. Prerequisite: set JAVA_HOME varriable. Example: export JAVA_HOME=\/usr\/IBM\/WebSphere\/AppServer\/java (this depends on your environment)<\/p>\n<p>Parameters for below examples:<\/p>\n<p>keystore Name: testcacerts.jks \/ test.kdb password: changeit \/ testit<\/p>\n<p>NOTE:- If you are practicing below examples kindly practice it in the [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6343"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6343"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6343\/revisions"}],"predecessor-version":[{"id":6344,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6343\/revisions\/6344"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}