---
title: 'icinga2 check_ssl_cert'
url: 'https://willifix.net/blog/icinga2-check_ssl_cert'
markdown: 'https://willifix.net/blog/icinga2-check_ssl_cert.md'
date: '2023-12-07'
description: 'I am often asked "how do you make sure your SSL certificates are valid?" My simple answer: I have built an icinga2 check for it :-) it is a simple Bashscript that gets triggerd once a day. #!/bin/bash #Created by ♞ Raffael Willems@im-c.de echo "Raffis SSL Cert Checker running..." if printf ''qu…'
---

# icinga2 check_ssl_cert

## [icinga2 check\_ssl\_cert](https://willifix.net/blog/icinga2-check_ssl_cert)

    7th Dec 2023  

I am often asked "how do you make sure your SSL certificates are valid?" My simple answer: I have built an icinga2 check for it :-)

it is a simple Bashscript that gets triggerd once a day.

```bash
 #!/bin/bash
 #Created by ♞ Raffael Willems@im-c.de

 echo "Raffis SSL Cert Checker running..."
 if printf 'quit\n' | openssl s_client -connect $2 -port $4   2>/dev/null | openssl x509 -checkend 604800 -noout
 then
   echo "Certificate is good for the next 7 Days!"
   exit 0
 else
   WANN=$(printf 'quit\n' | openssl s_client -connect $2 -port $4  2>/dev/null | openssl x509 -enddate -noout)
   echo $WANN
   exit 1
 fi
 # d=$(LC_ALL=en_US.utf8 date +%b\ %_d)
```

feel free to use it. it gets a lot of problems out of my way!

 [Next Post ](https://willifix.net/blog/filebeat-bind-plugin)

---

## Navigation

- Parent: [Blog](https://willifix.net/blog.md)
- Previous: [filebeat bind plugin](https://willifix.net/blog/filebeat-bind-plugin.md)
