Uncategorized

SSL Certificate Monitoring Script

You can easily monitor the live SSL certificate expiration with openssl commands.I will attach the script , the script will read the URLs from a text file and check for the certificate expiration. If the certificate is expiring in 30 days , it can send an email communication to the people needed. You can schedule a cron to run the job everyday.

Here is the script.

#!/bin/ksh

##
# ssl-cert-expiration-checker.sh
#
# Checks SSL certificate expiration dates. Sends a notification email if
# certificate expiration dates are sooner than the configured threshold.
#
# Expects a file named “certificate_cn_list.txt” to be located in the same
# directory as the script; this file should contain a list of hostnames whose
# SSL certificates should be checked (one per line). The name of this file
# can be changed by changing the value of variable CN_LIST_FILENAME.
#
# Original author: Sreekar
##

umask 077

MAIL_SUBJECT=”SSL certificate expiration warning”
MAIL_TO=”mail@mail.com”

CN_LIST_FILENAME=”certificate_cn_list.txt”

date2julian()
{
if [ “${1} != “” ] && [ “${2} != “” ] && [ “${3}” != “” ]
then
## Since leap years add aday at the end of February,
## calculations are done from 1 March 0000 (a fictional year)
d2j_tmpmonth=$((12 * ${3} + ${1} – 3))
## If it is not yet March, the year is changed to the previous year
d2j_tmpyear=$(( ${d2j_tmpmonth} / 12))
echo $(( (734 * ${d2j_tmpmonth} + 15) / 24 – 2 * ${d2j_tmpyear} + ${d2j_tmpyear}/4 – ${d2j_tmpyear}/100 + ${d2j_tmpyear}/400 + $2 + 1721119 ))
else
echo 0
fi
}

getmonth()
{
case ${1} in
Jan) echo 1 ;;
Feb) echo 2 ;;
Mar) echo 3 ;;
Apr) echo 4 ;;
May) echo 5 ;;
Jun) echo 6 ;;
Jul) echo 7 ;;
Aug) echo 8 ;;
Sep) echo 9 ;;
Oct) echo 10 ;;
Nov) echo 11 ;;
Dec) echo 12 ;;
*) echo 0 ;;
esac
}

date_diff()
{
if [ “${1}” != “” ] && [ “${2}” != “” ]
then
echo $((${2} – ${1}))
else
echo 0
fi
}

### Baseline the dates so we have something to compare to
MONTH=$(date “+%m”)
DAY=$(date “+%d”)
YEAR=$(date “+%Y”)
NOWJULIAN=$(date2julian ${MONTH#0} ${DAY#0} ${YEAR})

WARNDAYS=30

while read APPLICATION_URL
do
CERTDATE=`openssl s_client -host $APPLICATION_URL -port 443 -showcerts </dev/null 2>/dev/null | sed -n ‘/BEGIN CERTIFICATE/,/END CERT/p’ | openssl x509 -text 2>/dev/null | sed -n ‘s/ *Not After : *//p’`
set — $CERTDATE
MONTH=$(getmonth ${1})
CERTJULIAN=$(date2julian ${MONTH#0} ${2#0} ${4})
CERTDIFF=$(date_diff ${NOWJULIAN} ${CERTJULIAN})

echo “*************************************”
echo “SSL certificate for ${APPLICATION_URL} expires in $CERTDIFF days”

if [ $CERTDIFF -lt $WARNDAYS ]
then
echo “SSL certificate for ${APPLICATION_URL} expires in $CERTDIFF days” >> body.txt
echo >> body.txt

echo “Certificate expires sooner than warning threshold (${WARNDAYS} days)”
fi
done < “${CN_LIST_FILENAME}”

echo “*************************************”

mailx -s “${MAIL_SUBJECT}” “${MAIL_TO}” < body.txt
rm body.txt

Uncategorized

SOA WSM Policy Manager failing to start

In SOA  Policy manager(WSM) suddenly started failing  by throwing below error in the logs, other node WSM instance is fine with no issues. To test it , go to your weblogic console and try the http://host:port/wsm-pm ,It throws  error

<Jul 1, 2014 1:35:54 PM EDT> <Error> <oracle.as.cache> <BEA-000000> <

oracle.ias.cache.NetworkException: J2EE JOC-058 distributed cache initialization failure
J2EE JOC-043 base exception:
J2EE JOC-823 unable to contact the packet-distributor at [localhost:20030] segID=0
at oracle.ias.cache.groupv2.Client.init(Client.java:86)
at oracle.ias.cache.groupv2.GroupMember.<init>(GroupMember.java:383)
at oracle.ias.cache.groupv2.GroupMember.create(GroupMember.java:93)
at oracle.ias.cache.groupv2.GrpCommunication.init(GrpCommunication.java:141)
at oracle.ias.cache.groupv2.GrpCommunication.init(GrpCommunication.java:121)
at oracle.ias.cache.Net.init(Net.java:104)
at oracle.ias.cache.CacheInternal.initNet(CacheInternal.java:2924)
at oracle.ias.cache.CacheInternal.init(CacheInternal.java:695)
at oracle.ias.cache.CacheInternal.init(CacheInternal.java:343)
at oracle.ias.cache.CacheInternal.createNamedCache(CacheInternal.java:2601)
at oracle.ias.cache.Cache.createNamedCache(Cache.java:661)
at oracle.mds.internal.cache.JOCCacheProvider.createNamedCacheInternal(JOCCacheProvider.java:292)
at oracle.mds.internal.cache.JOCCacheProvider.createNamedCache(JOCCacheProvider.java:255)
at oracle.mds.internal.cache.JOCCacheProvider.<init>(JOCCacheProvider.java:87)
at oracle.mds.core.MDSInstance.initCache(MDSInstance.java:1620)
at oracle.mds.core.MDSInstance.<init>(MDSInstance.java:1758)
at oracle.mds.core.MDSInstance.<init>(MDSInstance.java:1710)
at oracle.mds.core.MDSInstance.findAndStoreMDSInstance(MDSInstance.java:2006)
at oracle.mds.core.MDSInstance.getOrCreateInstance(MDSInstance.java:516)
at oracle.mds.core.MDSInstance.getOrCreateInstance(MDSInstance.java:479)
at oracle.adf.share.config.ADFMDSConfig.createMDSInstanceFromelement(ADFMDSConfig.java:251)
at oracle.adf.share.config.MDSConfigFactory.createApplication(MDSConfigFactory.java:123)
at oracle.adf.share.config.ADFConfigFactory.findOrCreateADFConfig(ADFConfigFactory.java:142)
at oracle.adf.share.config.ADFConfigFactory.findOrCreateADFConfig(ADFConfigFactory.java:78)
at oracle.adf.share.config.ADFConfigFactory.findOrCreateADFConfig(ADFConfigFactory.java:56)
at oracle.adf.share.ADFContext.getADFConfigEx(ADFContext.java:891)

 

To Resolve this follow below steps:

 

Solution 1: ( This worked for me )

For 2 Nodes –

1. The AdminServer was incorrectly started up on both nodes. Shut them both down.

2. NodeManager was not started on the second node. Start it up.

3. Shutdown all soa_server managed servers, then bring them all up again (AdminServer, soa_server1, soa_server2)

Solution 2:

This could be due to the Java Object Cache (JOC) of OWSM needing to be reconfigured.

1. Stop all managed servers, except the AdminServer.

2. Run the following commands on SOAHOST1 only:

cd $MW_HOME/oracle_common/common/bin
./wlst.sh

3. Connect as follows:

wls:/offline> connect()
Please enter your username : weblogic
Please enter your password : welcome1
Please enter your server URL [t3://localhost:7001] :
Connecting to t3://adminhost:7001 with userid weblogic …
Successfully connected to Admin Server ‘AdminServer’ that belongs to domain ‘soa_domain’.

4. Execute the configure-joc.py script:

execfile(‘/u01/app/oracle/middleware/oracle_common/bin/configure-joc.py’)

Enter Hostnames (eg host1,host2) : soahost1,soahost2
Do you want to specify a cluster name (y/n) <y>y
Enter Cluster Name : soacluster
Enter Discover Port : 9991
Enter Distribute Mode (true|false) <true> : true
Do you want to exclude any server(s) from JOC configuration (y/n) <n>n

5. Start all managed servers.

Applicable Versions:

  • Oracle SOA Suite 11g (11.1.1.5)