Tuesday, 14 June 2016

Certificate Management using commands - Part 1



There are various command line tool to manage keys, certificates and certificate requests. Below are the commands available for certificate management:
- gskcmd and gskcapicmd ( Version 8 onwards)
- gsk7cmd and gsk7capicmd (version 7)


Syntax for the gsk cmds :

gskcmd <object> <action> [options]
where
object includes one of the following:

    • -keydb: Actions taken on the key database (either a CMS key database file, a WebDB key ring file, or SSLight class)
    • -cert: Actions taken on a certificate
    • -certreq: Actions taken on a certificate request
    • -help: Displays help for the gsk7cmd invocations
    • -version: Displays version information for gsk7cmd
action represents the specific action to take on the object.
options represents the options, both required and optional, specified for the object and action pair


Note: The object and action keywords are positional and you must specify them in the selected order. However, options are not positional and you can specify them in any order, as an option and operand pair.
The following table describes each action possible on a specified object that you can use with the gsk commands .


commands Object Action Description
gskcapicmd, gsk7capicmd,gskcmd gsk7cmd -keydb -changepw Change the password for a key database
-convert Convert the format of a key database
-create Create a key database
-delete Delete a key database
-expiry Display password expiry
-list Currently supported types of key database
-stashpw Stash the password of a key database into a file
gskcapicmd, gsk7capicmd, gskcmd, gsk7cmd -cert -add Add a CA Certificate
-create  Create a self-signed certificate
-delete Delete a certificate
-details Show the details of a specific certificate
-export  Export a personal certificate and associated private key into a PKCS12 file or a key database
-extract Extract a certificate from a key database
-getdefault Show the default personal certificate
-import Import a certificate from a key database or a PKCS12 file
-list List certificates in a key database
-listsigners List signer certificates delivered with ikeyman (not avaliable in gskcapicmd /gsk7capicmd)
-modify Modify a certificate (NOTE: the only field that may be modified is the trust field)
-populate Populate with included CA Certificates (not avaliable in gskcapicmd /gsk7capicmd)
-receive Receive a certificate
-rename Rename a certificate
-setdefault Set the default personal certificate
-sign  Sign a certificate
Available only in gskcmd and gskcapicmd -validate Validate a certificate path
gskcapicmd, gsk7capicmd, gskcmd and gsk7cmd -certreq -create  Create a certificate request
-delete Delete a certificate request from a certificate request database
-details Show the details of a specific certificate request
-extract Extract a certificate from a certificate request database
-list List all certificate requests in a certificate request database
-recreate Recreate a certificate request
Available only gskcmd and gsk7cmd -seckey -create  Create a secret key
-delete Delete a secret key
-details Show the details of a specific secret key
-export Export secret keys to a file
-import  Import secret keys from a file
-list List all secret keys in a key database
-rename Rename a secret key
gskcapicmd, gsk7capicmd, gskcmd and gsk7cmd -version   Display iKeyman version information
-help   Display this help text
avaliable only in gskcapicmd -secretkey -add Add a secret key
-extract Extract a secret key from a key database
-random -create Create a random password


The following table describes the options that you can use with the gsk  commands.


Option  Description
-db Fully qualified path name of a key database
-default_cert Sets a certificate to use as the default certificate for client authentication (yes or no). Default is no.
-dn X.500 distinguished name. Input as a quoted string of the following format (only CN, O, and C are required): "CN=Reena,O=IBM,OU=WebSphere,L=Bangalore, ST=KA,ZIP=13760,C=country" 
encryption Strength of encryption used in certificate export command (strong or weak). Default is strong.
-expire Expiration time of either a certificate or a database password (in days).
-file File name of a certificate or certificate request (depending on specified object).
-format Format of a certificate (either ASCII for Base64_encoded ASCII or binary for Binary DER data). Default is ASCII.
-label Label attached to a certificate or certificate request
-new_format New format of key database
-new_pw New database password
-old_format Old format of key database
-pw Password for the key database or PKCS#12 file
-size Key size (512, 1024, or 2048). Default is 1024. The 2048 key size is available if you are using Global Security Kit (GSKit) Version 7.0.4.14 and later.
-stash Indicator to stash the key database password to a file. If specified, the password will be stashed in a file.
-target Destination file or database
-target_pw Password for the key database if -target specifies a key database. 
-target_type Type of database specified by -target operand (see -type)
-trust Trust status of a CA certificate (enable or disable). Default is enable.
-type Type of database. Allowable values are CMS (indicates a CMS key database), webdb (indicates a keyring), sslight (indicates an SSLight .class), or pkcs12 (indicates a PKCS#12 file).
-x509version Version of X.509 certificate to create (1, 2 or 3). Default is 3.


Procedure

  1. You can invoke the gsk7cmd from the <ihsinst>/bin/ directory.
    • gsk7cmd.bat /gsk7capicmd.bat /gskcmd.bat /gskcapicmd.bat  (windows)
    • gsk7cmd /gsk7capicmd /gskcmd /gskcapicmd ( unix)
  2. Perform the certificate management tasks that you want to complete.
Example:
Create keystore with expiry for 20 years:
gsk7cmd -keydb -create -db test.kdb -pw password -type kdb -expire 7300


In next post (Certificate Management Using Command - Part 2 Keystore Management) , I will be covering the keystore management using the command with examples

Friday, 20 May 2016

WebSphere JVM startup issue

Troubleshoot : WebSphere JVM hangs during start-up



Issue: When WebSphere JVM is initiated to start, it hangs. no logs are written in SystemOut.log or SystemErr.log.


Environment details:
WebSphere 7.0.0.39 is installed on the Solaris.


Steps tried to resolve the issue:
  1. Kill the Process using the command kill -3 < JVM process id> so that the dump are created and we can check for some information.
  2. Below error messages were in the dump:
Found one Java-level deadlock:                                         
  ===                                                                  
  "Outbound Read Selector.1" daemon prio=3 tid=0x0000000103903800      
    nid=0x33 waiting for monitor entry [0xffffffff6c5fe000]            
    java.lang.Thread.State: BLOCKED (on object monitor)                
  at java.util.logging.LogManager.initializeGlobalHandlers             
     (LogManager.java:1333)                                            
  - waiting to lock <0xfffffffe11551600>                               
    (a com.ibm.ws.bootstrap.WsLogManager)                              
  at java.util.logging.LogManager.access$1500(LogManager.java:128)     
  at java.util.logging.LogManager$RootLogger.accessCheckedHandlers     
     (LogManager.java:1432)                                            
  at java.util.logging.Logger.getHandlers(Logger.java:1260)            
  - locked <0xfffffffe1159bcb0>                                        
    (a java.util.logging.LogManager$RootLogger)                        
  at java.util.logging.Logger.log(Logger.java:512)                     
  at com.ibm.ws.logging.WsLogger.deliverOrBuffer(WsLogger.java:286)    
  at com.ibm.ws.logging.WsLogger.log(WsLogger.java:264)                
  at com.ibm.ws.logging.WsLogger.logp(WsLogger.java:466)               
  at com.ibm.nws.ejs.ras.TraceComponent.debug(TraceComponent.java:132) 
  at com.ibm.nws.ejs.ras.Tr.debug(Tr.java:120)                         
  at com.ibm.ws.tcp.channel.impl.ChannelSelector.run                   
  at java.lang.Thread.run(Thread.java:682)                             
  ===                                                                  
  "P=697699:O=0:CT" prio=3 tid=0x000000010011b800                      
   nid=0x2 waiting for monitor entry [0xffffffff7baf9000]              
   java.lang.Thread.State: BLOCKED (on object monitor)                 
  at java.util.logging.Logger.getHandlers(Logger.java:1260)            
  - waiting to lock <0xfffffffe1159bcb0>                               
    (a java.util.logging.LogManager$RootLogger)                        
  at java.util.logging.Logger.log(Logger.java:512)                     
  at com.ibm.ws.logging.WsLogger.deliverOrBuffer(WsLogger.java:286)    
  at com.ibm.ws.logging.WsLogger.log(WsLogger.java:264)                
  at com.ibm.ws.logging.WsLogger.logp(WsLogger.java:499)               
  at com.ibm.ws.logging.WsLoggerConfigurator.logMessage                
     (WsLoggerConfigurator.java:569)                                   
  at com.ibm.ws.logging.WsLoggerConfigurator                           
     .getCurrentLoggingConfiguration(WsLoggerConfigurator.java:314)    
  at com.ibm.ws.logging.WsLoggerConfigurator                           
     .getLoggerConfiguration(WsLoggerConfigurator.java:123)            
  at com.ibm.ws.logging.WsLoggerConfigurator                           
     .configureLogger(WsLoggerConfigurator.java:375)                   
  at com.ibm.ws.logging.WsLoggerFactoryImpl.createWsLogger             
     (WsLoggerFactoryImpl.java:80)                                     
  at com.ibm.ws.bootstrap.RASDelegator.createWsLogger                  
     (RASDelegator.java:74)                                            
  at com.ibm.ws.bootstrap.WsLogManager.getLogger(WsLogManager.java:220)
  - locked <0xfffffffe11551600> (a com.ibm.ws.bootstrap.WsLogManager)
 
Check whether trace level is set.
It was observed that trace was set to *=finest and hence the JVM did not start up completely.
Removed the trace level and changed to *=info and started the JVM successfully.

We all know that logging is important as it provides valuable information when it comes to troubleshooting. But at the same time we need to understand that it comes with extra cost when it comes to performance. It is resource expensive. It is advisable that when we use logging/tracing we should use it on specific object. Excessive logging can over kill the performance.                        
                                                                       
Hence We should be having the trace spec set for specific object
e.g.     com.ibm.ejs.ras.*=all

Note: *=finest is not a good practice. Same is applicable for *=all.

Thursday, 19 May 2016

Websphere Node agent Synchronization Issue

TroubleShooting: Synchronization problem with Node agent



Issue: Node status shows not synchronized in the  administrative console


Error message:
[18/05/16 14:56:23:059 EST] 000000a3 NodeSyncTask  A   ADMS0036E: The configuration synchronization failed.
[18/05/16 14:56:24:088 EST] 000000a4 NodeSync      E   ADMS0012E: The system is unable to create an administrative client connection: com.ibm.websphere.management.exception.AdminException: Admin client connection to deployment manager is unavailable; nodeagent has not discovered the dmgr
 at com.ibm.ws.management.sync.NodeSync.getAdminClient(NodeSync.java:532)
 at com.ibm.ws.management.sync.NodeSync.getCellRepositoryEpoch(NodeSync.java:407)
 at com.ibm.ws.management.sync.NodeSyncTask.doSync(NodeSyncTask.java:248)
 at com.ibm.ws.management.sync.NodeSyncTask.run(NodeSyncTask.java:157)
 at java.lang.Thread.run(Thread.java:790)
.
[18/05/16 14:56:24:088 EST] 000000a4 NodeSync      E   ADMS0005E: The system is unable to generate synchronization request: com.ibm.websphere.management.exception.AdminException: Admin client connection to deployment manager is unavailable; nodeagent has not discovered the dmgr
 at com.ibm.ws.management.sync.NodeSync.getAdminClient(NodeSync.java:532)
 at com.ibm.ws.management.sync.NodeSync.getCellRepositoryEpoch(NodeSync.java:407)
 at com.ibm.ws.management.sync.NodeSyncTask.doSync(NodeSyncTask.java:248)
 at com.ibm.ws.management.sync.NodeSyncTask.run(NodeSyncTask.java:157)
 at java.lang.Thread.run(Thread.java:790)


Environment details: WAS 8.5.5.9 on Windows,  with both DMGR and Node agent created on the same system.


Steps tried to resolve Synchronization issue
1.      Stopped the Node agent and did a manually sync using the command syncNode.bat. Sync was successful. Started the node agent but on the console, still it showed the status as not synchronized.

2.      Tried to check the NODE_DISCOVERY_ADDRESS port for the node agent whether it is listening using the command:

 netstat -anbo | findstr "NODE_DISCOVERY_ADDRESS port number "

3.      NODE_DISCOVERY_ADDRESS port number was not listening though the node agent was running.

4.      Rebooted the Windows server and it fixed the issue as there would be some windows policy set and applied and requires a reboot.
Now Node agent status shows synchronized.


Wednesday, 2 December 2015

Quick guide to Installation Manager

Overview

 IBM® Installation Manager is a single installation program that uses remote or local software repositories to install, modify, roll back, and uninstall packages or update certain IBM products.

 Before we install Installation Manager on your target machines, we must consider what mode we will use to deploy packages. The mode that we choose determines how we install the software. There are three modes: administrator, non-administrator, and group.

Administrator : This mode is required for packages that require administrator or root privileges to be deployed. It can only be installed once per machine.
Non-administrator : We use this mode when users have their own copy of an application. We cannot use this mode where packages require administrator access. It can be installed once per user.
Group : We use this mode when we use multiple user accounts to manage the installed applications.
 

Installing or updating Installation Manager

Learn how to install or update IBM® Installation Manager.

Installing Installation Manager

You can install Installation Manager in wizard mode, command-line mode, silent mode, or console mode.
For step-by-step installation instructions on installing Installation Manager, select the appropriate topic.

Updating Installation Manager

For step-by-step installation instructions on updating Installation Manager, select the appropriate topic.


Command-line arguments for the imcl command

You must run the imcl commands from the tools directory.  The directory is given below:
Operating System Administrator Nonadministrator Group
Windows XP Professional C:\Program Files\IBM\Installation Manager\eclipse\tools C:\Documents and Settings\user\IBM\
Installation Manager\eclipse\tools
Not available
Windows Vista, Windows 2008, Windows 7, Windows 8, and Windows 2012 C:\Program Files [(x86)]\IBM\Installation Manager\eclipse\tools C:\Users\user\IBM\Installation Manager\eclipse\tools Not available
Linux and UNIX /opt/IBM/InstallationManager/
eclipse/tools
/user_home_directory/IBM/
InstallationManager/eclipse/tools
/user_home_directory/IBM/
InstallationManager_Group/eclipse/tools

Use the below link to learn more about the commands and options for the Installation Manager command line, imcl :
http://www-01.ibm.com/support/knowledgecenter/SSDV2W_1.8.3/com.ibm.cic.commandline.doc/topics/r_tools_imcl.html


Commonly used imcl commands:

Command to list the available packages to install :
./imcl listAvailablePackages -repositories source_repository

Eg:
bash-3.2$ cd /opt/IBM/InstallationManager/eclipse/tools
bash-3.2$ ./imcl listAvailablePackages -repositories /var/WAS855FP6/WAS/
com.ibm.websphere.BASE.v85_8.5.5006.20150529_0536
com.ibm.websphere.BASETRIAL.v85_8.5.5006.20150529_0536
com.ibm.websphere.DEVELOPERS.v85_8.5.5006.20150529_0536
com.ibm.websphere.DEVELOPERSILAN.v85_8.5.5006.20150529_0536
com.ibm.websphere.EXPRESS.v85_8.5.5006.20150529_0536
com.ibm.websphere.EXPRESSTRIAL.v85_8.5.5006.20150529_0536
com.ibm.websphere.ND.v85_8.5.5006.20150529_0536
com.ibm.websphere.NDDMZ.v85_8.5.5006.20150529_0536
com.ibm.websphere.NDDMZTRIAL.v85_8.5.5006.20150529_0536
com.ibm.websphere.NDTRIAL.v85_8.5.5006.20150529_0536
bash-3.2$
 

Command to install:
./imcl install package
  -repositories source_repository
  -installationDirectory installation_directory
  -sharedResourcesDirectory shared_directory
  -preferences preference_key=value
  -properties property_key=value
  -acceptLicense


Command to list available fixes:
./imcl listAvailableFixes com.ibm.product.package_1.0.0 -repositories "location or path of the Installation Files" -long


Command to list installed package:
imcl listInstalledPackages

Eg:
bash-3.2$ ./imcl listInstalledPackages
com.ibm.cic.agent_1.7.4003.20150630_1330
com.ibm.websphere.ND.v85_8.5.5006.20150529_0536
bash-3.2$