# security.txt Expiry, Encryption-Key Resolvability (`kingii98/security-txt-expiry-encryption-key-resolvability`) Actor

Checks security.txt files for expiry, unresolvable OpenPGP keys and unreachable contacts. Keeps a ledger of changes between runs.

- **URL**: https://apify.com/kingii98/security-txt-expiry-encryption-key-resolvability.md
- **Developed by:** [kingii98](https://apify.com/kingii98) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$5.00 / 1,000 domain checkeds

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

## security.txt Expiry, Encryption-Key Resolvability, and Contact Reachability Ledger

This Actor checks the RFC 9116 `security.txt` file of each domain you give it. It tells you
before a reporter finds out that a file has expired, that a listed OpenPGP key cannot be
fetched, or that a Contact URL is not reachable. It keeps a ledger between runs, so it also
reports what changed.

### What the Actor does for each domain

1. It fetches `https://<domain>/.well-known/security.txt`. If that fails, it fetches `/security.txt`.
2. It reads `Contact`, `Expires`, `Encryption`, and `Canonical`. It accepts PGP-signed files.
3. It finds up to 3 `Encryption` keys. A key is an `openpgp4fpr:` fingerprint or a URL.
   For a URL, the Actor downloads the key and reads its fingerprint and expiry.
   Then it asks each selected keyserver for that fingerprint.
4. If `checkContactUrls` is true, it sends a HEAD request to up to 2 `https:` Contact values.
   It does not check `mailto:` or `tel:` values. A status below 400 means reachable.
   Some servers refuse HEAD requests. They show as not reachable.
5. It compares the result with the state from the last run and stores the new state.

### Input

| Field | Default | Meaning |
| --- | --- | --- |
| `domains` | `["curl.se", "github.com"]` | 1 to 1000 hostnames. |
| `expiryLeadDays` | `30` | Status is `due` when `Expires` is less than this number of days away. |
| `keyservers` | `keys.openpgp.org`, `keyserver.ubuntu.com` | Keyservers to ask. |
| `checkContactUrls` | `true` | HEAD check for `https:` Contact values. |
| `stateStoreName` | `stx-key-ledger` | Named key-value store for ledger state. |

An empty input `{}` works. Every field has a default.

### Output

One dataset item per domain. Main fields:

- `servedLocation`, `httpStatus`, `contentType`, `isPgpSigned`
- `expires`, `daysToExpiry`, `expiryStatus` (`ok`, `due`, `expired`, or `missing`)
- `canonicalMatchesServedUrl` (`null` when the file has no `Canonical`)
- `contacts[]` with `reachable` (`null` when not checked)
- `encryptionKeys[]` with `source` (`URL` or `fingerprint`), `fingerprint`, `resolvedOn[]`, `keyExpiry`,
  `reason` (`unsupported_scheme` when the value is not an `openpgp4fpr:` or `http(s)://` value,
  for example a `dns:` URI; `source` is `URL` for these values and they show as not resolved)
- `resolvedOn[]` and `keyExpiry` at top level (union of servers, first key expiry found)
- `changeEvents[]`: `expires_moved`, `key_added`, `key_removed`, `contact_changed`, `file_removed`
- `alerts[]`: `expiry_due`, `expiry_expired`, `expires_missing`, `file_missing`,
  `key_unresolved`, `key_expired`, `contact_unreachable`
- `error`: a reason code when the check could not finish

The first run for a domain has no `changeEvents`, because no earlier state exists.

The run also writes a `SUMMARY` record to the default key-value store. It has counts by
`expiryStatus`, alert count, change-event count, and charge data.

A failed check is a normal result. A missing file, an expired file, or an unreachable target
does not fail the run. The run fails only on a real malfunction.

### Pricing event

The pricing model is pay-per-event. The Actor calls `Actor.charge` once per domain with
this event:

| Event name | Unit | Planned price |
| --- | --- | --- |
| `domain-checked` | One domain: security.txt fetched, keys resolved, and ledger updated. | $0.005 |

The Actor does not charge for an invalid hostname, for a private or reserved target, or for a
domain that does not resolve in DNS. If the charge limit is reached, the Actor stops and
reports the skipped domains in `SUMMARY`. You set the price in Apify Console. This
repository does not change pricing.

### Safety limits

- HTTP only. No browser, proxy, LLM, paid API, or secret.
- Only `https:` on port 443. Private, loopback, link-local, and reserved addresses are rejected.
  The Actor checks every redirect target too.
- At most 3 redirects, 64 KB per response, 10 s per request, 30 s per fetch, 5 domains at once.
- Known limit: the Actor resolves a hostname before it connects. It does not pin the address.
  A hostile DNS server could still change the answer between the two steps.
- Known limit: key downloads stop at 1 MiB. A larger key shows as not resolved.
- Known limit: the OpenPGP reader supports v4 keys only. Other key versions show as not resolved.

### Development

```
uv run pytest
uv run ruff check .
```

# Actor input Schema

## `domains` (type: `array`):

Hostnames to check, for example example.com. Minimum 1, maximum 1000. Private and reserved targets are rejected.

## `expiryLeadDays` (type: `integer`):

Alert when the Expires date is less than this number of days away.

## `keyservers` (type: `array`):

Keyservers that the Actor asks for each OpenPGP key.

## `checkContactUrls` (type: `boolean`):

Send a HEAD request to https: Contact values. The Actor does not check mailto: or tel: values.

## `stateStoreName` (type: `string`):

Name of the key-value store that keeps the ledger state between runs.

## Actor input object example

```json
{
  "domains": [
    "curl.se",
    "github.com"
  ],
  "expiryLeadDays": 30,
  "keyservers": [
    "keys.openpgp.org",
    "keyserver.ubuntu.com"
  ],
  "checkContactUrls": true,
  "stateStoreName": "stx-key-ledger"
}
```

# Actor output Schema

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

No description

## `summary` (type: `string`):

No description

# 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 = {
    "domains": [
        "curl.se",
        "github.com"
    ],
    "expiryLeadDays": 30,
    "keyservers": [
        "keys.openpgp.org",
        "keyserver.ubuntu.com"
    ],
    "checkContactUrls": true,
    "stateStoreName": "stx-key-ledger"
};

// Run the Actor and wait for it to finish
const run = await client.actor("kingii98/security-txt-expiry-encryption-key-resolvability").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 = {
    "domains": [
        "curl.se",
        "github.com",
    ],
    "expiryLeadDays": 30,
    "keyservers": [
        "keys.openpgp.org",
        "keyserver.ubuntu.com",
    ],
    "checkContactUrls": True,
    "stateStoreName": "stx-key-ledger",
}

# Run the Actor and wait for it to finish
run = client.actor("kingii98/security-txt-expiry-encryption-key-resolvability").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 '{
  "domains": [
    "curl.se",
    "github.com"
  ],
  "expiryLeadDays": 30,
  "keyservers": [
    "keys.openpgp.org",
    "keyserver.ubuntu.com"
  ],
  "checkContactUrls": true,
  "stateStoreName": "stx-key-ledger"
}' |
apify call kingii98/security-txt-expiry-encryption-key-resolvability --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kingii98/security-txt-expiry-encryption-key-resolvability"
        }
    }
}
```

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/5Y62JZfwjt1K7bOlP/builds/dffinyyajURcLjZsu/openapi.json
