<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RE: Script for RADIUS certificate monitoring in Analytics &amp; Visibility</title>
    <link>https://community.extremenetworks.com/t5/analytics-visibility/script-for-radius-certificate-monitoring/m-p/51514#M27</link>
    <description>Hello Michael,&lt;BR /&gt;
&lt;BR /&gt;
very helpful. Thanks a lot.&lt;BR /&gt;
&lt;BR /&gt;
Stephan&lt;BR /&gt;
&lt;BR /&gt;</description>
    <pubDate>Thu, 22 Jan 2015 14:32:00 GMT</pubDate>
    <dc:creator>Stephan_Harrer</dc:creator>
    <dc:date>2015-01-22T14:32:00Z</dc:date>
    <item>
      <title>Script for RADIUS certificate monitoring</title>
      <link>https://community.extremenetworks.com/t5/analytics-visibility/script-for-radius-certificate-monitoring/m-p/51510#M23</link>
      <description>Dear Community,&lt;BR /&gt;
as currently NAC does not have any certificate monitoring (see: &lt;A href="https://community.extremenetworks.com/extreme/topics/nac_alarm_if_radius_certificate_is_about_to_expire" target="_blank" rel="nofollow noreferrer noopener"&gt;https://community.extremenetworks.com/extreme/topics/nac_alarm_if_radius_certificate_is_about_to_exp...&lt;/A&gt;) I wrote a script to monitor the RADIUS certificate which I want to share with you. Feel free to use it but please respect the author naming&lt;BR /&gt;
&lt;BR /&gt;
I realized two types of "alarming".&lt;BR /&gt;
1) (Aktive): Syslog message to NetSight Server&lt;BR /&gt;
2) OneFabric API: logEvent. (For this a credentialfile is necessary&lt;BR /&gt;
3) Alammanager Config.&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="fancybox-image"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="cbc47b60959343bea6969b32c98052a4_RackMultipart20150121-4175-1zfteg-Syslog_inline.png"&gt;&lt;img src="https://community.extremenetworks.com/t5/image/serverpage/image-id/2084iE8C1C4A1380C5076/image-size/large?v=v2&amp;amp;px=999" role="button" title="cbc47b60959343bea6969b32c98052a4_RackMultipart20150121-4175-1zfteg-Syslog_inline.png" alt="cbc47b60959343bea6969b32c98052a4_RackMultipart20150121-4175-1zfteg-Syslog_inline.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="fancybox-image"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="cbc47b60959343bea6969b32c98052a4_RackMultipart20150121-29502-1eoyl8g-Alarm_inline.png"&gt;&lt;img src="https://community.extremenetworks.com/t5/image/serverpage/image-id/2953i730CF808FFAA2F57/image-size/large?v=v2&amp;amp;px=999" role="button" title="cbc47b60959343bea6969b32c98052a4_RackMultipart20150121-29502-1eoyl8g-Alarm_inline.png" alt="cbc47b60959343bea6969b32c98052a4_RackMultipart20150121-29502-1eoyl8g-Alarm_inline.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="fancybox-image"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="cbc47b60959343bea6969b32c98052a4_RackMultipart20150121-28598-ol2vu3-Alarm_Manager_inline.png"&gt;&lt;img src="https://community.extremenetworks.com/t5/image/serverpage/image-id/4197iF44A0AFD95310B6D/image-size/large?v=v2&amp;amp;px=999" role="button" title="cbc47b60959343bea6969b32c98052a4_RackMultipart20150121-28598-ol2vu3-Alarm_Manager_inline.png" alt="cbc47b60959343bea6969b32c98052a4_RackMultipart20150121-28598-ol2vu3-Alarm_Manager_inline.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
To use the sciprt:&lt;BR /&gt;
&lt;BR /&gt;
1) Copy Script to NAC Appliance eg. /root/custom/&lt;BR /&gt;
2) Set permissions chmod 744 /root/custom/checkcert.sh&lt;BR /&gt;
3) Set automatic execution via crontab -e eg. 0 0 * * * /root/custom/checkcert.sh&lt;BR /&gt;
&lt;BR /&gt;
If you have any ideas for improvement or any other comment please feel free to share &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Best Regards&lt;BR /&gt;
Michael&lt;BR /&gt;
&lt;BR /&gt;
#!/bin/bash#####################################################&lt;BR /&gt;
# Author: Michael Kirchner, Unify GmbH &amp;amp; Co. KG  #&lt;BR /&gt;
# E-Mail: michael.kirchner@unify.com    #&lt;BR /&gt;
# This script is free to use with the limitation #&lt;BR /&gt;
# of naming the author.        #&lt;BR /&gt;
# Description: This script is used to monitor the  #&lt;BR /&gt;
# RADIUS certificate of the NAC Appliance   #&lt;BR /&gt;
#####################################################&lt;BR /&gt;
#Date: 01/21/2015&lt;BR /&gt;
&lt;BR /&gt;
# Usage:&lt;BR /&gt;
# 1) Copy Script to NAC Appliance eg. /root/custom/&lt;BR /&gt;
# 2) Set permissions chmod 744 /root/custom/checkcert.sh&lt;BR /&gt;
# 3) Set automatic execution via crontab -e eg. 0 0 * * * /root/custom/checkcert.sh&lt;BR /&gt;
&lt;BR /&gt;
DATEDIFF=0&lt;BR /&gt;
CERTDATE=0&lt;BR /&gt;
CERTDATE1=0&lt;BR /&gt;
CERTDATE2=0&lt;BR /&gt;
CERTSFILE=0&lt;BR /&gt;
TODAY=$(date '+%s')&lt;BR /&gt;
WARNLEVEL=100 # 100 Days before Certificate expires&lt;BR /&gt;
SUBJECT=0&lt;BR /&gt;
SERIAL=0&lt;BR /&gt;
CONFIG=/opt/nac/server/config/config.properties # Path of the NAC Config&lt;BR /&gt;
RADIUSPATH=/opt/nac/radius/raddb/certs/external_server.pem # Path of the RADIUS Certificate&lt;BR /&gt;
#OFCONNECTPATH=/axis/services/BasicReporting/logEvent # OneFabric Connect Path for LogEvent&lt;BR /&gt;
NSSERVER="" # NetSight Server&lt;BR /&gt;
NACHOST="" # NAC Appliance Hostname&lt;BR /&gt;
#USER="" # used for OneFabric Connect API&lt;BR /&gt;
#PASS="" # used for OneFabric Connect API&lt;BR /&gt;
#CREDFILE=./cred # Credential File used for OneFabric Connect API&lt;BR /&gt;
MESSAGE=""&lt;BR /&gt;
&lt;BR /&gt;
#Function extracts Date from Certificate File&lt;BR /&gt;
function extractEndDate()&lt;BR /&gt;
{&lt;BR /&gt;
 CERTDATE=$(openssl x509 -in $CERTSFILE -noout -enddate | cut -f2 -d=)&lt;BR /&gt;
     CERTDATE1=$(date --date="$CERTDATE" '+%s')&lt;BR /&gt;
 CERTDATE2=$(date --date="$CERTDATE" '+%Y-%m-%d')&lt;BR /&gt;
}&lt;BR /&gt;
#Function extracts the Subject of the Certificate File&lt;BR /&gt;
function extractSubject()&lt;BR /&gt;
{&lt;BR /&gt;
 SUBJECT=$(openssl x509 -in $CERTSFILE -noout -subject | cut -f2 -d" ") &lt;BR /&gt;
}&lt;BR /&gt;
#Function extracts the Serialnumber of the Certificate File&lt;BR /&gt;
function extractSerial()&lt;BR /&gt;
{&lt;BR /&gt;
 SERIAL=$(openssl x509 -in $CERTSFILE -noout -serial | cut -f2 -d=) &lt;BR /&gt;
}&lt;BR /&gt;
# Abort&lt;BR /&gt;
function die()&lt;BR /&gt;
{&lt;BR /&gt;
    echo ERROR: $1&lt;BR /&gt;
    exit 1&lt;BR /&gt;
}&lt;BR /&gt;
#Function gets Information (NetSight Server, NAC Appliance Hostname)&lt;BR /&gt;
function getInfos()&lt;BR /&gt;
{&lt;BR /&gt;
 NSSERVER=$(cat $CONFIG | grep NETSIGHT_SERVER | cut -d"=" -f2)&lt;BR /&gt;
 NACHOST=$(cat $CONFIG | grep NACHOSTNAME | cut -d"=" -f2)&lt;BR /&gt;
 #USER=$(cat $CREDFILE | grep USER | cut -d"=" -f2)&lt;BR /&gt;
 #PASS=$(cat $CREDFILE | grep PASSWORD | cut -d"=" -f2)&lt;BR /&gt;
}&lt;BR /&gt;
function warn()&lt;BR /&gt;
{&lt;BR /&gt;
    echo "WARNING: $1"&lt;BR /&gt;
}&lt;BR /&gt;
CERTSFILE=$RADIUSPATH&lt;BR /&gt;
&lt;BR /&gt;
# Test if file exists, if so then print the expiration date of certificate.&lt;BR /&gt;
if [ -e $CERTSFILE ] ; &lt;BR /&gt;
  then&lt;BR /&gt;
    extractEndDate $CERTSFILE&lt;BR /&gt;
 DATEDIFF=$(( ($CERTDATE1 - $TODAY) / 86400 ))&lt;BR /&gt;
 extractSubject&lt;BR /&gt;
 extractSerial&lt;BR /&gt;
 getInfos&lt;BR /&gt;
 if [ $WARNLEVEL -gt $DATEDIFF ]&lt;BR /&gt;
  then&lt;BR /&gt;
   &lt;BR /&gt;
   if [ $DATEDIFF -gt 0 ]&lt;BR /&gt;
    then&lt;BR /&gt;
     MESSAGE="NAC NAC RADIUS Certificate $SUBJECT @ $NACHOST with serial $SERIAL is about to expire in $DATEDIFF days at $CERTDATE2"&lt;BR /&gt;
    &lt;BR /&gt;
    else&lt;BR /&gt;
     MESSAGE="NAC NAC RADIUS Certificate $SUBJECT  @ $NACHOST is expired"&lt;BR /&gt;
   fi&lt;BR /&gt;
  else&lt;BR /&gt;
   MESSAGE="NAC NAC RADIUS Certificate $SUBJECT @ $NACHOST serial $SERIAL is valid. Expiry Date: $CERTDATE2 (still $DATEDIFF left)"&lt;BR /&gt;
 fi&lt;BR /&gt;
 #OneFabric Connect&lt;BR /&gt;
 #$(curl --insecure --data "category=NAC Alert&amp;amp;source=$NACHOST&amp;amp;title=RADIUS Certificate Alert&amp;amp;message=$MESSAGE" https://$USER:$PASS@$NSSERVER:8443$OFCONNECTPATH)&lt;BR /&gt;
 &lt;BR /&gt;
 #Generation of a Syslog Message to NetSight Server&lt;BR /&gt;
 nc -w0 -u $NSSERVER  514 &amp;lt;&amp;lt;&amp;lt; "&amp;lt;14&amp;gt;$MESSAGE"&lt;BR /&gt;
&lt;BR /&gt;
  else &lt;BR /&gt;
     die $CERTSFILE" file does not exist."&lt;BR /&gt;
     exit 2&lt;BR /&gt;
fi&lt;BR /&gt;
&lt;BR /&gt;
exit 0&lt;BR /&gt;
&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jan 2015 21:07:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/analytics-visibility/script-for-radius-certificate-monitoring/m-p/51510#M23</guid>
      <dc:creator>Michael_Kirchne</dc:creator>
      <dc:date>2015-01-21T21:07:00Z</dc:date>
    </item>
    <item>
      <title>RE: Script for RADIUS certificate monitoring</title>
      <link>https://community.extremenetworks.com/t5/analytics-visibility/script-for-radius-certificate-monitoring/m-p/51511#M24</link>
      <description>Hi Michael, &lt;BR /&gt;
&lt;BR /&gt;
great work this helps a lot &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Cheers!</description>
      <pubDate>Wed, 21 Jan 2015 21:19:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/analytics-visibility/script-for-radius-certificate-monitoring/m-p/51511#M24</guid>
      <dc:creator>Philipp_Tittman</dc:creator>
      <dc:date>2015-01-21T21:19:00Z</dc:date>
    </item>
    <item>
      <title>RE: Script for RADIUS certificate monitoring</title>
      <link>https://community.extremenetworks.com/t5/analytics-visibility/script-for-radius-certificate-monitoring/m-p/51512#M25</link>
      <description>I agree - great work and absolutely useful! Thanks for sharing it!&lt;BR /&gt;
Kurt</description>
      <pubDate>Wed, 21 Jan 2015 21:38:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/analytics-visibility/script-for-radius-certificate-monitoring/m-p/51512#M25</guid>
      <dc:creator>Kurt_Semba</dc:creator>
      <dc:date>2015-01-21T21:38:00Z</dc:date>
    </item>
    <item>
      <title>RE: Script for RADIUS certificate monitoring</title>
      <link>https://community.extremenetworks.com/t5/analytics-visibility/script-for-radius-certificate-monitoring/m-p/51513#M26</link>
      <description>This is exactly the kind of post we like to see here.  Thanks for sharing!&lt;BR /&gt;
&lt;BR /&gt;
-Drew&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Jan 2015 03:25:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/analytics-visibility/script-for-radius-certificate-monitoring/m-p/51513#M26</guid>
      <dc:creator>Drew_C</dc:creator>
      <dc:date>2015-01-22T03:25:00Z</dc:date>
    </item>
    <item>
      <title>RE: Script for RADIUS certificate monitoring</title>
      <link>https://community.extremenetworks.com/t5/analytics-visibility/script-for-radius-certificate-monitoring/m-p/51514#M27</link>
      <description>Hello Michael,&lt;BR /&gt;
&lt;BR /&gt;
very helpful. Thanks a lot.&lt;BR /&gt;
&lt;BR /&gt;
Stephan&lt;BR /&gt;
&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Jan 2015 14:32:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/analytics-visibility/script-for-radius-certificate-monitoring/m-p/51514#M27</guid>
      <dc:creator>Stephan_Harrer</dc:creator>
      <dc:date>2015-01-22T14:32:00Z</dc:date>
    </item>
  </channel>
</rss>

