This project provides a powerful Telegram bot and a RESTful API to check X.509 digital certificate validity, OCSP status, CRL updates, and more.
- โ
Supports
.cer,.cert,.pemcertificates - ๐ฅ Auto-converts .der, .cer, .p7b to .pem format directly in chat
- ๐ ๏ธ Fixes malformed .pem files by adding missing headers automatically
- ๐ฆ Extracts certificates from .p7b/.p7c and sends .zip of .pem files using /pem with file description
- ๐จโ๐ผ Capricorn .pem certificate can be updated via /changecert (admin-only)
- ๐ซ Blocks spam users automatically
- ๐ Real-time OCSP monitoring for Capricorn CA (Capricorn Identity Services Pvt. Ltd.) DSC
- โ๏ธ JSON & XML API support
- ๐ฌ Telegram Bot: @OCSP_CRL_bot
- Upload a certificate file or paste base64 string
- Auto-detect
.pem,.der, and even.p7bfiles - Convert any uploaded certificate to .pem format using /pem caption
- Automatically fixes malformed .pem uploads missing headers
- ๐ Extracts certificates from .p7b/.p7c and returns .zip with individual .pem files using
/pemin file caption - /changecert command to update Capricorn .pem certificate from Telegram directly (admin only)
- ๐ Convert
.pemor.p7b/.p7cfiles to .cer / .der / base64 format using/certin caption and get format options via inline buttons - Auto-warns and blocks spammers after 10 invalid attempts
- Admin panel to unblock users
- Live monitoring of Capricorn
.pemOCSP status - โฐ Sends OCSP failure alerts to your group only once per hour to prevent spam
- ๐ Supports multiple groups automatically:
- When the bot is added to a group, its chat ID is saved automatically in .env
- When the bot is removed or kicked from a group, that chat ID is removed from .env
- ๐งน OCSP alerts are auto-deleted after 5 minutes from each group
- ๐ฎ Admin (
MONITOR_USER_ID) gets notified when bot is added to or removed from a group - ๐งน Automatically deletes the alert message after 5 minutes
- ๐ฎโโ๏ธ Requires Admin Rights in the group to send and delete messages
- No manual chat ID setup needed anymore
- Bot auto-saves any group it's added to
- Auto-removes chat ID when kicked or removed
- Keeps
.envupdated live - Admin gets a notification when bot is removed from any group
- Accepts
POSTrequests with JSON or XML - Validates certificate format
- Checks OCSP & CRL status
- Returns structured response
- Rejects
.p7bfiles via API with user-friendly error
git clone https://github.com/Aniketc068/OCSPMonitorBot.git
cd OCSPMonitorBot- Python 3.6 or higher
- Windows, macOS, or Linux
python -m venv ocsp
pdf\Scripts\activatepython3 -m venv ocsp
source pdf/bin/activatepip install -r requirements.txtIf you are using Windows, keep these imports as they are
from waitress import serve
If you are using Linux or Mac, remove the waitress import above
and uncomment/use this import instead:
from gunicorn.app.base import BaseApplication๐ What is MASTER_TOKEN? The MASTER_TOKEN is a secure authentication token used by the API to verify if the client requesting a new token is trusted. Only clients that provide the correct MASTER_TOKEN are issued valid short-lived access tokens for calling protected endpoints (like /api/certchecker).
This mechanism prevents unauthorized access and abuse of the certificate validation API.
โ๏ธ How to Generate the MASTER_TOKEN
We provide a helper script: env_setup.py This script helps you generate a strong MASTER_TOKEN and creates a .env file that will be used by your application.
NOTE: Please Genarate The Telegram Bot Token, User Chat-ID and Super Group Chat-ID
python env_setup.py For Windows
python3 python env_setup.py For macOS/Linuxpython main.py For Windows
python3 main.py For macOS/LinuxCreate a .env file or export them manually:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
TELEGRAM_CHAT_ID=-100xxxxxxxxxx,-100yyyyyyyyyy # โ
Bot supports multiple group chat IDs (comma-separated)
MONITOR_USER_ID=your_admin_chat_id # ๐ Gets notified on group add/removeEndpoint
POST /api/get-tokenHeaders
Content-Type: application/json OR application/xml
JSON Payload
{
"auth_token": "Your_MASTER_TOKEN"
}XML Payload
<request>
<auth_token>Your_MASTER_TOKEN</auth_token>
</request>โ Response If the auth_token is valid, you will receive a temporary token:
JSON
{
"token": "TEMPORARY_ACCESS_TOKEN"
}XML
<response>
<token>TEMPORARY_ACCESS_TOKEN</token>
</response>Endpoint
POST /api/certcheckerHeaders
Content-Type: application/json OR application/xml
Token: TEMPORARY_ACCESS_TOKEN
JSON Payload
{
"request": {
"command": "certchecker",
"data": "BASE64_ENCODED_CERT_HERE"
}
}XML Payload
<request>
<command>certchecker</command>
<data>BASE64_ENCODED_CERT_HERE</data>
</request>
| Status | Message | Description |
|---|---|---|
| 400 | Missing 'command' or 'data' field | Required fields are not found in the request |
| 400 | Invalid command. Expected 'certchecker' | Wrong command value sent |
| 400 | Invalid base64 certificate data | data field is not properly base64 encoded |
| 401 | Invalid master token | Provided master token is incorrect (in /api/get-token) |
| 400 | Token already used | Access token was already consumed |
| 400 | Token expired | Token was not used within 60 seconds |
| 400 | Missing or invalid token | Token is not passed in the header or not found |
- Python
- Flask
- python-telegram-bot (async)
- cryptography
- lxml / xml.etree.ElementTree
Made with โค๏ธ by Aniket Chaturvedi
