Welcome!

Article

Audit Certificate Inventory in WebSphere Application Server

Generate list of Certificates used in WebSphere Application Server environment

Introduction

A digital certificate is an electronic "passport" that allows a person, computer or organization to exchange information securely over the Internet using the public key infrastructure. A digital certificate may also be referred to as a public key certificate. The main purpose of the digital certificate is to ensure that the public key contained in the certificate belongs to the entity to which the certificate was issued.

Digital certificates package public keys, information about the algorithms used, owner or subject data, the digital signature of a Certificate Authority that has verified the subject data, and a date range during which the certificate can be considered valid. Certificates are signed by the Certificate Authority (CA) that issues them. In essence, a CA is a commonly trusted third party that is relied upon to verify the matching of public keys to identity, e-mail name, or other such information.

Any WebSphere administrator already know that managing the SSL certificates in a large complex environment becomes hectic and troublesome because of the different expiration dates of the certificates that WebSphere uses and also the SSL certificates of the external systems that WebSphere Application Server interact with using a secure connection. Multiple administrators in any organization renewing and managing certificates but not keeping track of the expiration dates of certificates.

The purpose of this document describes how to generate a report for all the certificates using in the WebSphere environment by using a simple Jython script. The script checks all certificates that are stored in keystores under Cell management. The script generates a report in the form of CSV file and the report contains the certificate type, Issues to (common name), Issued by, Expire in number of Days, Expiration Date, Keystore name and the scope of the certificate information.

Procedure

1- Create the following Jython script and name it “listCerts.jy”:

# --------------------------------------------------------------------------------

# listCerts.jy - Lists all the certs in WebSphere Application Server

# --------------------------------------------------------------------------------

# --------------------------------------------------------------------------------

# Setup

# --------------------------------------------------------------------------------

import re

import sys

import time

import os

import javaos

import shutil

from java.text import SimpleDateFormat ;

dateFormat = SimpleDateFormat("dd-MMM-yyyy");

expiryDateFormat = SimpleDateFormat("MMMMM dd, yyyy");

reportFile="/tmp/certs.csv"

try:

os.remove(reportFile)

except OSError:

pass

print "Generating certificate list in " + reportFile

#### Write CSV Headers ####

file = open(reportFile,'a')

file.write('"Cert Type","Issues To","Issued By","Expires In (days)","Expiry Date","Keystore Name", "Scope"' + "\n");

file.close()

# --------------------------------------------------------------------------------

# Define Subroutines

# --------------------------------------------------------------------------------

def dateDiff(keyStoreType, keystoreName, issuedTo, issuedBy, expString, scopeName):

todayString = time.strftime("%d-%b-%Y", time.gmtime())

todayDate = dateFormat.parse(todayString)

expiryDate = expiryDateFormat.parse(expString)

e = expiryDate.getTime()

t = todayDate.getTime()

d = e - t

days = d / (1000 * 60 * 60 * 24)

file = open(reportFile,'a')

file.write(str(keyStoreType) + ',"' + fmtStr(str(issuedTo)) + '","' + fmtStr(issuedBy) + '","' + fmtStr(str(days)) + '","' + str(expString) + '","' + fmtStr(str(keystoreName)) + '","' + fmtStr(str(scopeName)) + '"' + "\n");

file.close()

def find_between( s, first, last ):

try:

start = s.index( first ) + len( first )

end = s.index( last, start )

return s[start:end]

except ValueError:

return ""

def fmtStr(str):

str = str.replace('"', '')

str = str.replace(',',' ')

return str

# ---------------------------------------------------------------------------------------------------------------

# Main

# ---------------------------------------------------------------------------------------------------------------

# Iterate through all keystores, and generate list

for ks in AdminTask.listKeyStores('[-all true -keyStoreUsage SSLKeys ]').splitlines():

keystoreName = AdminConfig.showAttribute(ks, 'name')

ms = AdminConfig.showAttribute(ks, 'managementScope')

scopeName = AdminConfig.showAttribute(ms, 'scopeName')

personalCertsFound=0

for cert in AdminTask.listPersonalCertificates('[-keyStoreName '+keystoreName+' -keyStoreScope '+scopeName+']').splitlines():

personalCertsFound=1

issuedTo=""

issuedBy=""

for property in re.split("\] \[", cert):

if(re.search("\[\[", property)):

tmp = property

property = re.split("\[\[",tmp)[1]

if(re.search("] ]", property)):

tmp = property

property = re.split("] ]",tmp)[0]

if(re.search("alias", property)):

alias = re.split("\s+", property)[1]

if(re.search("issuedTo", property)):

issuedTo=property

if(re.search("issuedBy", property)):

issuedBy=property

if(re.search("validity", property)):

expString = find_between(property,"to ",".")

keyStoreType = "personal"

dateDiff(keyStoreType, keystoreName, issuedTo, issuedBy, expString, scopeName)

#if(personalCertsFound==0):

# print '\tNo personal certificates found in '+keystoreName+' in scope '+scopeName

signerCertsFound=0

for cert in AdminTask.listSignerCertificates('[-keyStoreName '+keystoreName+' -keyStoreScope '+scopeName+']').splitlines():

signerCertsFound=1

issuedTo=""

issuedBy=""

for property in re.split("\] \[", cert):

if(re.search("\[\[", property)):

tmp = property

property = re.split("\[\[",tmp)[1]

if(re.search("] ]", property)):

tmp = property

property = re.split("] ]",tmp)[0]

if(re.search("alias", property)):

alias = re.split("\s+", property)[1]

if(re.search("issuedTo", property)):

issuedTo=property

if(re.search("issuedBy", property)):

issuedBy=property

if(re.search("validity", property)):

expString = find_between(property,"to ",".")

type="signer"

dateDiff(type, keystoreName, issuedTo, issuedBy, expString, scopeName)

#if(signerCertsFound==0):

# print '\tNo signer certificates found in '+keystoreName+' in scope '+scopeName


2- Copy the “listCerts.jy” file on the Deployment manager server (in /tmp folder).

3- Change the user to WASUSER and the file permission, if needed

4- Go to the bin folder of the Deployment manager and run the following command

wsadmin.sh –lang jython –f /tmp/listCerts.jy –username <WASUSER> –password <WASPASSWORD>

5- Once the script executed, it will create “/tmp/certs.csv” file

6- Copy the “certs/csv” file on the desktop by using ftp/scp client

7- Review the csv file

Conclusion

The generated report captures the certificate type, Issues to (common name), Issued by, Expire in number of Days, Expiration Date, Keystore name and the scope of the certificate information. By running the script weekly or monthly basis and reviewing the generated report timely manner can avoid any server or SSL communication disruption due to expire certificate.


More Stories By Asim Saddal

Asim Saddal works in the Middleware (WebSphere Application Server, WebSphere Datapower, WebSphere Process Server, WebSphere VE) practice of IBM Software Services for WebSphere.

Latest Stories
DX World EXPO, LLC, a Lighthouse Point, Florida-based startup trade show producer and the creator of "DXWorldEXPO® - Digital Transformation Conference & Expo" has announced its executive management team. The team is headed by Levent Selamoglu, who has been named CEO. "Now is the time for a truly global DX event, to bring together the leading minds from the technology world in a conversation about Digital Transformation," he said in making the announcement.
"Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that Conference Guru has been named “Media Sponsor” of the 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. A valuable conference experience generates new contacts, sales leads, potential strategic partners and potential investors; helps gather competitive intelligence and even provides inspiration for new products and services. Conference Guru works with conference organizers to pass great deals to gre...
DevOps is under attack because developers don’t want to mess with infrastructure. They will happily own their code into production, but want to use platforms instead of raw automation. That’s changing the landscape that we understand as DevOps with both architecture concepts (CloudNative) and process redefinition (SRE). Rob Hirschfeld’s recent work in Kubernetes operations has led to the conclusion that containers and related platforms have changed the way we should be thinking about DevOps and...
The Internet of Things will challenge the status quo of how IT and development organizations operate. Or will it? Certainly the fog layer of IoT requires special insights about data ontology, security and transactional integrity. But the developmental challenges are the same: People, Process and Platform. In his session at @ThingsExpo, Craig Sproule, CEO of Metavine, demonstrated how to move beyond today's coding paradigm and shared the must-have mindsets for removing complexity from the develop...
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
The next XaaS is CICDaaS. Why? Because CICD saves developers a huge amount of time. CD is an especially great option for projects that require multiple and frequent contributions to be integrated. But… securing CICD best practices is an emerging, essential, yet little understood practice for DevOps teams and their Cloud Service Providers. The only way to get CICD to work in a highly secure environment takes collaboration, patience and persistence. Building CICD in the cloud requires rigorous ar...
Companies are harnessing data in ways we once associated with science fiction. Analysts have access to a plethora of visualization and reporting tools, but considering the vast amount of data businesses collect and limitations of CPUs, end users are forced to design their structures and systems with limitations. Until now. As the cloud toolkit to analyze data has evolved, GPUs have stepped in to massively parallel SQL, visualization and machine learning.
"Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
"ZeroStack is a startup in Silicon Valley. We're solving a very interesting problem around bringing public cloud convenience with private cloud control for enterprises and mid-size companies," explained Kamesh Pemmaraju, VP of Product Management at ZeroStack, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Large industrial manufacturing organizations are adopting the agile principles of cloud software companies. The industrial manufacturing development process has not scaled over time. Now that design CAD teams are geographically distributed, centralizing their work is key. With large multi-gigabyte projects, outdated tools have stifled industrial team agility, time-to-market milestones, and impacted P&L stakeholders.
"Akvelon is a software development company and we also provide consultancy services to folks who are looking to scale or accelerate their engineering roadmaps," explained Jeremiah Mothersell, Marketing Manager at Akvelon, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Enterprises are adopting Kubernetes to accelerate the development and the delivery of cloud-native applications. However, sharing a Kubernetes cluster between members of the same team can be challenging. And, sharing clusters across multiple teams is even harder. Kubernetes offers several constructs to help implement segmentation and isolation. However, these primitives can be complex to understand and apply. As a result, it’s becoming common for enterprises to end up with several clusters. Thi...