# Web Security, TLS Certificate & HTTP Headers Audit (MCP) (`the_magic_dragon/web-security-tls-headers-mcp`) Actor

Audit websites for TLS protocol/cipher strength, X.509 certificate expiry & SANs, HTTP security headers (HSTS, CSP, XFO, XCTO, Referrer-Policy, Permissions-Policy), server header disclosure, .well-known/security.txt, and DNS CAA records with deterministic 0-100 scores and A+ to F grades. MCP-ready.

- **URL**: https://apify.com/the_magic_dragon/web-security-tls-headers-mcp.md
- **Developed by:** [Cade Hockley](https://apify.com/the_magic_dragon) (community)
- **Categories:** AI, Developer tools, Business
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$4.00 / 1,000 host auditeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Web Security, TLS Certificate & HTTP Headers Audit (MCP)

Audit public websites and API endpoints for **TLS protocol & cipher strength**, **X.509 certificate validity & expiry**, **HTTP security headers**, **server stack disclosures**, **`/.well-known/security.txt`**, and **DNS CAA records** — returning a deterministic `0–100` security score, `A+` to `F` grade, and prioritized remediation recommendations.

Built for **Apify Pay-per-Event** and designed for **MCP / AI Agents** (`apify-mcp-server`), **n8n**, security posture monitoring, and B2B vendor risk workflows.

### Key Features

- **TLS Socket & X.509 Inspection:** Performs an SNI-enabled TLS handshake via Python `ssl` to capture `tlsVersion`, `cipherSuite`, certificate `subject`, `issuer`, `notBefore`, `notAfter`, `daysUntilExpiry`, `sanCount`, and `sanSample`, while flagging untrusted or expiring certificates.
- **Full HTTP Security Header Audit:** Executes HTTPS `GET` requests (capturing status codes including `403`/`404` and full redirect chains) to check:
  - `Strict-Transport-Security` (HSTS presence, `max-age >= 31536000`, `includeSubDomains`, `preload`)
  - `Content-Security-Policy` (presence, `default-src`, `frame-ancestors`)
  - `X-Frame-Options` & `X-Content-Type-Options` (`nosniff`)
  - `Referrer-Policy` & `Permissions-Policy`
  - `Server` and `X-Powered-By` version/stack disclosure
- **`security.txt` & DNS CAA Checks:** Optionally verifies `/.well-known/security.txt` (RFC 9116) and walks parent domains for DNS `CAA` records (RFC 8659) via `dnspython` with `/usr/bin/dig` fallback.
- **Deterministic Scoring (`0–100`, `A+` to `F`):** Transparent point breakdown across TLS (35 pts), HTTP security headers (55 pts), and security hygiene (10 pts).

### Pay-per-Event Pricing

- **Event:** `host-audited`
- **Price:** `$0.004` USD per valid host audited (`US$4.00` per 1,000 hosts)
- **Zero-Charge Guard:** Malformed or empty host inputs emit structured `status: "invalid_input"` records and are **never charged**.

### Input Schema Summary

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `hosts` | `string[]` | Required | Hostnames or URLs (e.g. `https://example.com/foo` normalizes to `example.com`). |
| `port` | `integer` | `443` | TCP port for TLS handshake and HTTPS requests. |
| `timeoutSeconds` | `integer` | `10` | Per-operation network timeout in seconds (`1–60`). |
| `checkSecurityTxt` | `boolean` | `true` | Fetch `/.well-known/security.txt` over HTTPS. |
| `checkCaaDns` | `boolean` | `true` | Query DNS `CAA` records across domain hierarchy. |
| `maxItems` | `integer` | `100` | Optional cap on valid hosts audited and charged per run. |

### Example Input

```json
{
  "hosts": [
    "google.com",
    "https://shopify.com/pricing"
  ],
  "port": 443,
  "timeoutSeconds": 10,
  "checkSecurityTxt": true,
  "checkCaaDns": true
}
```

### Example Output Item

```json
{
  "input": "https://shopify.com/pricing",
  "host": "shopify.com",
  "port": 443,
  "status": "ok",
  "ok": true,
  "securityScore": 84,
  "grade": "A",
  "tls": {
    "ok": true,
    "certVerified": true,
    "tlsVersion": "TLSv1.3",
    "daysUntilExpiry": 62,
    "sanCount": 2
  },
  "http": {
    "ok": true,
    "httpStatus": 200,
    "redirectCount": 1
  },
  "securityTxt": {
    "checked": true,
    "present": true,
    "status": 200
  },
  "caaDns": {
    "checked": true,
    "present": true,
    "queriedName": "shopify.com"
  },
  "findings": [],
  "recommendations": []
}
```

### MCP Integration (`apify-mcp-server`)

Connect this Actor to Claude Desktop, Cursor, or any MCP-compatible client via `mcp.apify.com`:

```json
{
  "mcpServers": {
    "apify": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://mcp.apify.com/?actors=the_magic_dragon/web-security-tls-headers-mcp",
        "--header",
        "Authorization: Bearer ${APIFY_TOKEN}"
      ]
    }
  }
}
```

# Actor input Schema

## `hosts` (type: `array`):

List of hostnames or URLs to audit (e.g. 'google.com', 'https://shopify.com/pricing'). URLs are normalized to hostnames.

## `port` (type: `integer`):

Target TCP port for TLS handshake and HTTPS inspection (default 443).

## `timeoutSeconds` (type: `integer`):

Per-operation socket and HTTP timeout in seconds (1-60).

## `checkSecurityTxt` (type: `boolean`):

Fetch /.well-known/security.txt over HTTPS to verify RFC 9116 vulnerability disclosure contact metadata.

## `checkCaaDns` (type: `boolean`):

Query DNS Certification Authority Authorization (CAA) records (walking parent domains per RFC 8659) via dnspython or dig fallback.

## `maxItems` (type: `integer`):

Optional cap on total valid host audits to execute and charge during a single run (1-500).

## Actor input object example

```json
{
  "hosts": [
    "google.com",
    "shopify.com"
  ],
  "port": 443,
  "timeoutSeconds": 10,
  "checkSecurityTxt": true,
  "checkCaaDns": true,
  "maxItems": 100
}
```

# Actor output Schema

## `results` (type: `string`):

Structured per-host TLS handshake, certificate expiry, HTTP security headers, security.txt, CAA DNS, score, grade, and findings records.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "hosts": [
        "google.com",
        "shopify.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("the_magic_dragon/web-security-tls-headers-mcp").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "hosts": [
        "google.com",
        "shopify.com",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("the_magic_dragon/web-security-tls-headers-mcp").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "hosts": [
    "google.com",
    "shopify.com"
  ]
}' |
apify call the_magic_dragon/web-security-tls-headers-mcp --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,the_magic_dragon/web-security-tls-headers-mcp"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/hL7zar1EPUeA3trcG/builds/wVMuljbhDctASewLi/openapi.json
