Guides · Web, domains and data

How do I check SSL certificates automatically in an AI agent?

Call ssl-check from a Pydantic AI tool function to read a domain's certificate: the issuer, the validity dates and how many days remain. It costs €0.03 a call.

  • Pydantic AI
  • Python

Steps

  1. Install straleio and pydantic-ai.
  2. Create the Strale client with your API key.
  3. Define a tool that calls ssl-check with a domain.
  4. Run the agent and read the expiry and issuer.

The solution

Python
# pip install straleio pydantic-ai
from straleio import Strale, DoRequest
from pydantic_ai import Agent

strale = Strale(api_key="sk_live_YOUR_KEY")

agent = Agent("openai:gpt-4o")


@agent.tool_plain
def check_ssl(domain: str) -> dict:
    """Check the TLS certificate for a domain."""
    result = strale.do(DoRequest(
        capability_slug="ssl-check",
        inputs={"domain": domain},
        max_price_cents=10,
    ))
    return result.output


response = agent.run_sync("Is the certificate for example.com valid, and when does it expire?")
print(response.output)

How it works

The tool connects to the domain, reads the certificate it presents and reports the issuer, valid_from and valid_to dates, is_expired, is_expiring_soon, days_until_expiry, the TLS protocol, the cipher and the subject alternative names.

Checking is_expiring_soon lets an agent raise an alert before a certificate lapses.

Tools in this guide

ToolPrice per call
SSL Certificate Check€0.03
DNS LookupFree
Security Header Check€0.05
Domain Reputation€0.05