{
  "id": "N8lYj0OOkpuJcota",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "SSL/TLS Certificate Expiry Monitor with Slack Alert",
  "tags": [],
  "nodes": [
    {
      "id": "6123946e-b16c-46e4-9fba-3d923a607289",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -224,
        -16
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "977d3ca9-ed8e-42d0-98c4-5bbbf40a7e7d",
      "name": "List Domains to Monitor",
      "type": "n8n-nodes-base.code",
      "position": [
        0,
        -16
      ],
      "parameters": {
        "jsCode": "const domainsToMonitor = [\n    \"your-company.com\",\n    \"mail.your-company.com\",\n    \"api.your-company.com\"\n];\n\nreturn domainsToMonitor.map(domain => ({ json: { domain } }));"
      },
      "typeVersion": 2
    },
    {
      "id": "200ddf00-400e-478c-9380-06c416bc154b",
      "name": "Check Certificate Expiry",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        224,
        -16
      ],
      "parameters": {
        "url": "=https://api.certspotter.com/v1/certinfo?domain={{ $json.domain }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "060cb358-a136-4653-b82b-1546ae87351b",
      "name": "Is Certificate Expiring?",
      "type": "n8n-nodes-base.if",
      "position": [
        448,
        -16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a73d70ba-5324-4964-8212-46c32caa4750",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{ new Date($json.result.expires) }}",
              "rightValue": "={{ new Date(Date.now() + 30 * 24 * 60 * 60 * 1000) }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a71bec8f-aa12-4eed-b67f-b28a94577f30",
      "name": "YOUR_SECURITY_ALERT_CHANNEL_ID",
      "type": "n8n-nodes-base.slack",
      "position": [
        672,
        -16
      ],
      "parameters": {
        "text": "=\ud83d\udea8 *URGENT: SSL Certificate Expiry Alert!* \ud83d\udea8\n\nDomain: *{{ $json.domain }}*\nExpires on: *{{ new Date($json.result.expires).toLocaleDateString() }}*\n\nPlease renew this certificate immediately to avoid downtime!",
        "user": {
          "__rl": true,
          "mode": "id",
          "value": "123123"
        },
        "select": "user",
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "eb0a1434-9d97-4744-8a60-61debe8ea595",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        -64
      ],
      "parameters": {
        "color": 3,
        "width": 1184,
        "height": 240,
        "content": "## Flow"
      },
      "typeVersion": 1
    },
    {
      "id": "2a070150-1bef-4e3c-aac5-093b9804f224",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        208
      ],
      "parameters": {
        "color": 5,
        "width": 1184,
        "height": 1184,
        "content": "### \ud83d\udca1 SSL/TLS Certificate Expiry Monitor \ud83d\uddd3\ufe0f\n\n* **Problem Solved:**\n    As an AI Agent developer, you know that expired SSL/TLS certificates can cause significant downtime, security warnings, and a loss of customer trust. Manually tracking the expiry dates for dozens or hundreds of domains is a tedious, error-prone, and unsustainable process. This often leads to certificates expiring unexpectedly, causing costly outages and broken services.\n\n* **Solution Overview:**\n    This n8n workflow provides a **proactive and automated solution for SSL/TLS certificate management**. It periodically checks the SSL certificate expiry date for a list of your domains using an external API. If it finds a certificate that's due to expire within a critical timeframe (e.g., 30 days), it sends a **high-priority alert to a designated Slack channel**. This automation ensures your team has ample time to renew certificates and prevent costly outages.\n\n* **For Whom:**\n    This automation is ideal for:\n    * **System Administrators:** To simplify the monitoring of domain certificates across all company assets.\n    * **DevOps Teams:** To integrate certificate checks into their continuous deployment and maintenance pipelines.\n    * **Web Developers & Site Owners:** To prevent website downtime and security warnings.\n    * **Managed Service Providers (MSPs):** To offer an essential uptime monitoring service to their clients.\n\n* **Scope:**\n    * **What it does:**\n        * Runs on a customizable schedule (e.g., once per week).\n        * Checks the SSL/TLS certificate expiry date for a list of specified domains.\n        * Uses an external API to reliably get certificate information.\n        * Sends a detailed alert to a Slack channel if a certificate is expiring within a configurable number of days.\n    * **What it doesn't do:**\n        * This workflow **does not automatically renew certificates**. Its purpose is to alert the team so they can take action.\n        * It does not check for other domain-related issues (e.g., DNS records, domain ownership expiry). It is focused solely on certificate expiry.\n\n### How to Set Up\nHere's a step-by-step guide to get this workflow running in your n8n instance.\n\n1.  **Prepare Your Credentials & API:**\n    * **Certificate Expiry API:** You need an API to check certificate expiry. We'll use a sample API for the workflow, so you might need to adjust the URL and parameters. For production use, you may need a service like Certspotter or a similar tool.\n    * **Slack Credential:** Set up a **Slack credential** in n8n and get the **Channel ID** of your security alert channel (e.g., `#security-alerts`).\n\n2.  **Import the Workflow JSON:**\n    * Create a new workflow in n8n and choose \"Import from JSON.\"\n    * Paste the JSON code for the \"SSL/TLS Certificate Expiry Monitor\" workflow.\n\n3.  **Configure the Nodes:**\n    * **Scheduled Check (Cron):** Set the schedule according to your preference (e.g., every Monday at 8:00 AM).\n    * **List Domains to Monitor (Code):** Edit the `domainsToMonitor` array in the code and add all the domains you want to check.\n    * **Check Certificate Expiry (HTTP Request):** Update the **URL** to match the certificate checking API you are using.\n    * **Is Certificate Expiring? (If):** The logic is set to check for expiry within 30 days. You can adjust the `30` in the expression `new Date(Date.now() + 30 * 24 * 60 * 60 * 1000)` to change the warning period.\n    * **Send Alert (Slack):** Select your **Slack credential** and enter the correct **Channel ID**.\n\n4.  **Test and Activate:**\n    * **Manual Test:** Run the workflow manually to confirm it fetches certificate data and processes it correctly. You can test with a domain that you know is expiring soon to ensure the alert is triggered.\n    * **Verify Output:** Check your Slack channel to confirm that alerts are formatted and sent correctly.\n    * **Activate:** Once you're confident everything works, activate the workflow. n8n will now automatically monitor your domain certificates on the schedule you set."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "b8997d0d-d03b-424e-baeb-cda8afc9dd4c",
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "List Domains to Monitor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List Domains to Monitor": {
      "main": [
        [
          {
            "node": "Check Certificate Expiry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Certificate Expiry": {
      "main": [
        [
          {
            "node": "Is Certificate Expiring?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Certificate Expiring?": {
      "main": [
        [
          {
            "node": "YOUR_SECURITY_ALERT_CHANNEL_ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}