Secure an AtlasMart Elasticsearch deployment from first boot by separating HTTP TLS, transport TLS, certificate trust, enrollment/bootstrap artifacts, realms, and long-lived application identities.

Secure-by-Default Principles, Node/HTTP TLS, Certificates, Trust, and Enrollment/Bootstrap Concepts

Design equivalent AtlasMart retention intent in Elastic and OpenSearch while documenting non-equivalent lifecycle, tiering, policy-update, simulation, and managed-service behavior.

Intermediate → Advanced110–145 minutesTLS, trust, realms & bootstrap securityElasticsearch 9.5.3 · Kibana 9.5.3 · OpenSearch comparison: 3.8.0Last reviewed: September 2026

Learning outcomes

AtlasMart’s developers can reach a fresh Elasticsearch node, but the first implementation stores the elastic superuser password in an application environment file and disables certificate verification because “it is only internal.” That collapses bootstrap authority, transport trust and application identity into one secret. This lesson separates those mechanisms before any application role is created.

01

Distinguish HTTP TLS from transport TLS and explain which peers each channel authenticates.

02

Validate an Elasticsearch HTTP certificate against the generated CA instead of bypassing verification.

03

Explain first-start security auto-configuration, the elastic bootstrap administrator and short-lived enrollment tokens.

04

Separate certificate trust, user authentication, realms and role authorization as independent controls.

05

Replace the superuser-as-application anti-pattern with a staged least-privilege identity plan.

Chapter baseline reviewed 11 September 2026

Examples target the official self-managed Elasticsearch 9.5.3 / Kibana 9.5.3 distribution, reviewed 11 September 2026. The lab reuses atlasmart-es at https://localhost:9200, the generated HTTP CA copied earlier as atlasmart-es-http-ca, and ELASTIC_PASSWORD only as a bootstrap administrator credential. Use curl --cacert; never teach -k as an Elasticsearch security shortcut. The official distribution includes a bundled OpenJDK and Elastic recommends using it; no external JVM is required by this lab. Kibana examples assume 9.5.3 when UI behavior matters. OpenSearch 3.8.0 is mentioned only to mark non-portable boundaries; Chapter 20 teaches its Security plugin separately.

Subscription boundary

Encrypted communications, native/file authentication, core role-based access control, Kibana Spaces, and API-key management are available in the free Basic self-managed distribution. Document/field-level security and Elasticsearch/Kibana audit logging are subscription-sensitive features; verify the current Elastic subscription matrix for your deployment before using them as mandatory controls. The mandatory lab therefore succeeds on Basic with index-level RBAC, separate identities and short-lived API keys, and presents DLS/FLS/audit as an optional extension plus a deterministic fallback.

Safety boundary

Never paste passwords, API-key secrets, service tokens, private keys or CA private material into lesson HTML, source control, shell transcripts or screenshots. The examples use environment variables and display only identifiers or expected response shapes.

Execution note

The generation environment does not run the AtlasMart Docker cluster, so requests are deterministic lab instructions and response fragments are expected shapes/invariants, not fabricated captures. Record your own certificate fingerprints/expiry, 401/403 evidence, key identifiers/expiration, audit events where licensed, and application p95/p99 latency under authenticated load.

1. Start with channels, not usernames

Elasticsearch has two network planes that are easy to conflate. The HTTP layer is the REST interface used by applications, Kibana and administrators, normally on port 9200. The transport layer is Elasticsearch’s internal node-to-node protocol, normally on port 9300. In a secured multi-node cluster, transport uses mutual TLS so cluster members authenticate each other. HTTP TLS encrypts and authenticates the server to clients and can optionally participate in client-certificate authentication when PKI realms are configured.

Control Question answered AtlasMart rule
HTTP TLS Is this client talking to the intended Elasticsearch endpoint over an encrypted channel? Trust the generated HTTP CA; no -k.
Transport TLS Are participating nodes authenticated/encrypted members of the same cluster trust domain? Use the cluster transport CA/certificates; not application credentials.
Authentication Who is making this request? Native user, API key, token, service account, realm-backed identity, etc.
Authorization What may that identity do? Roles/privileges decide cluster, index, application and run-as actions.
Audit What security-relevant event was recorded? A separate observable control; availability depends on subscription/configuration.

2. Observe automatic security setup without turning it into permanent architecture

On a first eligible self-managed start, Elasticsearch 9.5.3 can automatically enable security, generate HTTP and transport certificates, configure TLS settings, set the elastic superuser password, and create a Kibana enrollment token. An enrollment token is a bootstrap artifact used to establish trusted initial configuration; it is not a reusable application bearer token. Kibana enrollment tokens are short-lived (the current auto-setup documentation states 30 minutes).

Inspect the secured endpoint and authenticated identity
# PowerShell/Git Bash variables are examples; do not commit their values.
export ES_URL="https://localhost:9200"
export ES_CA="/path/to/http_ca.crt"
export ELASTIC_USER="elastic"
# ELASTIC_PASSWORD should come from your local secret store/session.

curl --fail --silent --show-error \
  --cacert "$ES_CA" \
  -u "$ELASTIC_USER:$ELASTIC_PASSWORD" \
  "$ES_URL/_security/_authenticate?pretty"

Expected invariant: the call succeeds only when both the TLS trust decision and the credential are valid. The authentication response identifies the principal, authentication realm/type and roles. It does not prove the principal is least-privileged.

3. Prove certificate trust instead of disabling it

TLS evidence with OpenSSL
openssl s_client \
  -connect localhost:9200 \
  -CAfile "$ES_CA" \
  -verify_return_error \
  -servername localhost </dev/null

Capture the subject/SAN, issuer, validity dates and verification result. A certificate can be cryptographically valid but still be wrong for the hostname; hostname verification is part of server identity. If your production clients connect through search.atlasmart.example, the certificate must be valid for that name rather than merely for localhost.

Deliberately wrong local test
# WRONG: this removes server-certificate verification.
curl -k -u "$ELASTIC_USER:$ELASTIC_PASSWORD" https://localhost:9200/

# CORRECT: trust the CA that signed the server certificate.
curl --cacert "$ES_CA" -u "$ELASTIC_USER:$ELASTIC_PASSWORD" "$ES_URL/"
What the repair proves

CA verification proves that the presented certificate chains to a trusted issuer and matches the endpoint identity under the client’s verification rules. It does not prove the application credential is appropriately scoped; authorization is tested separately.

4. Realms identify users; roles authorize them

A realm is an authentication mechanism that can identify users. Native and file realms are straightforward self-managed choices; other realm types such as LDAP/Active Directory, PKI, SAML/OIDC/JWT/Kerberos have distinct configuration and subscription/deployment constraints. Do not design “LDAP role JSON” as if realm configuration and RBAC are the same layer. A user can authenticate successfully and still receive a 403 because its roles do not authorize the requested action.

Inspect authentication before authorization design
GET /_security/_authenticate
GET /_security/user
GET /_security/role

The chapter’s mandatory lab uses the native realm for reproducibility. That is a learning choice, not a claim that every production organization should manage human identities natively.

5. Bootstrap authority is intentionally too powerful for applications

The built-in elastic superuser is appropriate for controlled bootstrap and emergency administration. It is deliberately inappropriate for AtlasMart search or ingest processes because compromise grants cluster-wide authority. The correct progression is: bootstrap securely, create narrow roles and identities, validate forbidden operations, create/rotate machine credentials, then reduce how often humans need the bootstrap credential.

Create the chapter fixture as administrator
PUT atlasmart-products-secure-v1
{
  "settings": {"number_of_shards": 1, "number_of_replicas": 0},
  "mappings": {
    "dynamic": "strict",
    "properties": {
      "sku": {"type":"keyword"},
      "name": {"type":"text", "fields":{"keyword":{"type":"keyword"}}},
      "category": {"type":"keyword"},
      "tenant_id": {"type":"keyword"},
      "price": {"type":"scaled_float", "scaling_factor":100},
      "cost_internal": {"type":"scaled_float", "scaling_factor":100},
      "updated_at": {"type":"date"}
    }
  }
}

6. Boundary: Elastic security APIs are not OpenSearch Security APIs

OpenSearch 3.8.0 uses the OpenSearch Security plugin with its own certificates, internal users, roles, role mappings, tenants and REST APIs. Shared ancestry does not make /_security/role, Elastic enrollment tokens, Elastic service accounts or Kibana Spaces portable. Chapter 20 builds the OpenSearch model directly. This chapter compares only enough to prevent accidental cross-product assumptions.

7. Production judgment

Certificate rotation, CA ownership, private-key storage, network exposure, reverse proxies/load balancers and managed-cloud boundaries belong in the threat model. Monitor certificate expiry before outages occur. Separate administrator endpoints from application paths where network controls permit. Measure authentication/TLS overhead in the real topology, but do not trade server identity verification for marginal latency.

Check your understanding

  1. Why are HTTP TLS and transport TLS separate concepts?
  2. What does the automatic enrollment token represent?
  3. Why is curl -k unsafe as a normal lab pattern?
  4. Does successful /_security/_authenticate prove least privilege?
  5. Why not keep using elastic in AtlasMart services?
Review the answers

1. HTTP TLS protects client-to-Elasticsearch REST traffic; transport TLS protects/authenticates node-to-node cluster traffic.

2. A short-lived bootstrap mechanism for initial trusted enrollment, not a reusable application credential.

3. It disables certificate verification and teaches clients to accept an unauthenticated endpoint.

4. No. It proves authentication; authorization must be tested with allowed and forbidden operations.

5. Its superuser blast radius is far larger than an application needs; dedicated roles/keys make compromise and rotation containable.

Summary and next step

Preserve the evidence, assumptions, version boundaries, and safety checks established in this lesson. Carry them into the next lesson—or, at the end of the capstone, into the production runbook—rather than treating this lesson as an isolated recipe.

References

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only Ethereum or ERC-20 compatible assets to this address.