vector icon indicating copy to clipboard operation
vector copied to clipboard

SSL errors in log with http_endpoint with tls

Open robinpecha opened this issue 1 year ago • 5 comments

A note for the community

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Problem

Hi, Im collecting journald and docker logs and sending it to http_endpoint sink on another vector instance. This connection is encrypted with tls.

SENDER:

sources:
  dockerlogs:
    type: docker_logs
  journald:
    type: journald
sinks:
  https:
    type: http
    inputs: 
      - journald
      - dockerlogs
      # - host_metrics
      # - host_metrics_remap
    uri: "https://vector-receiver.example.com:8888"
    encoding: { codec: "json" }
    tls:
      verify_certificate: true
      ca_file:  "/etc/vector/tls/vector-server.crt"
      crt_file: "/etc/vector/tls/vector-client.crt"
      key_file: "/etc/vector/tls/vector-client.key"
    auth:
      strategy: basic
      user: user
      password: password

RECEIVER:

sources:
   https_endpoint:
    type: http_server
    address: "0.0.0.0:8888"
    encoding: json
    tls:
      enabled: true
      verify_certificate: true
      ca_file:  "/etc/vector/tls/vector-client.crt"
      crt_file: "/etc/vector/tls/vector-server.crt"
      key_file: "/etc/vector/tls/vector-server.key" 
    auth:
      type: basic
      username: user
      password: password

Here is output of vector top. 5 820 000 sucessfully sent logs, 1 error Image

But log of vector is full of errors like this, each few minutes:

Jan 28 09:06:54 dev-vm-1 vector[1723162]: 2025-01-28T08:06:54.392456Z  WARN sink{component_kind="sink" component_id=https component_type=http}:request{request_id=7935}: vector::sinks::util::retries: Retrying after error. error=Failed to make HTTP(S) request: error trying to connect: error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:ssl/record/rec_layer_s3.c:908:SSL alert number 80 internal_log_rate_limit=true

Configuration

Debian GNU/Linux 12 (bookworm)
Linux dev-vm-1 6.1.0-22-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.94-1 (2024-06-21) x86_64 GNU/Linux

Version

vector 0.43.0 (x86_64-unknown-linux-gnu 88e017f 2024-12-03 22:44:54.502541095)

Debug Output


Example Data

No response

Additional Context

No response

References

No response

robinpecha avatar Jan 28 '25 08:01 robinpecha

Hey @robinpecha, this could be a mismatch between Client and Server certificates. Here are some things to try:

  • Try disabling verify_certificate to see if it’s purely a trust issue.
  • Enable VECTOR_LOG=debug to get more detailed logs.
  • Ensure TLS version compatibility

pront avatar Feb 03 '25 17:02 pront

I reproduced this deterministically with Vector 0.56.0 and 0.57.0 using mTLS between a Vector sink and source.

A fresh TLS 1.2 handshake succeeds. Saving that session with openssl s_client -sess_out and reconnecting with -sess_in fails with:

tlsv1 alert internal error
SSL alert number 80

Another fresh handshake succeeds immediately.

This appears to be a server-side session-resumption bug. When verify_certificate: true, Vector sets PEER | FAIL_IF_NO_PEER_CERT, but does not set an OpenSSL session ID context:

https://github.com/vectordotdev/vector/blob/v0.57.0/lib/vector-core/src/tls/settings.rs#L271-L344

OpenSSL documents that session reuse with client-certificate verification fails fatally when the session ID context is unset:

https://docs.openssl.org/3.6/man3/SSL_CTX_set_session_id_context/

trace-storm avatar Jul 26 '26 16:07 trace-storm

I am also having this issue, tried so many certificate work arounds and re-adding the agent. Still sporadically get: WARN sink{component_kind="sink" component_id=central component_type=vector}:request{request_id=139}: vector::sinks::util::retries: Retrying after error. error=Request failed: status: Unavailable, message: "error trying to connect: error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:ssl/record/rec_layer_s3.c:918:SSL alert number 80", details: [], metadata: MetadataMap { headers: {} }

OscarsWorldTech avatar Aug 14 '26 03:08 OscarsWorldTech

Hello @pront and Vector Team,

As @cloudradar-net mentioned this seems to be a bug indeed. We can replicate it on our side as well.

I'll try to summarize my and others discovery in a single post:

Summary

When a TLS client attempts to resume a previous TLS session against a Vector http/opentelemetry source configured with tls.verify_certificate: true (mTLS, client certificate required), the server sends a fatal internal_error alert (TLS alert 80) and the connection fails. A fresh (non-resumed) handshake against the same server succeeds without issue. It seems to affect not only http/opentelemetry sources - but vector one as well.

Full error

{"timestamp":"2026-08-28T15:13:26.257556Z","level":"WARN","message":"HTTP error.","error":"error trying to connect: error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:ssl/record/rec_layer_s3.c:916:SSL alert number 80","error_type":"request_failed","stage":"processing","target":"vector::internal_events::http_client","span":{"name":"http"},"spans":[{"component_id":"vectorInput","component_kind":"sink","component_type":"opentelemetry","name":"sink"},{"request_id":21145,"name":"request"},{"name":"http"}]}

{"timestamp":"2026-08-28T15:13:26.257726Z","level":"WARN","message":"Retrying after error.","error":"Failed to make HTTP(S) request: error trying to connect: error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:ssl/record/rec_layer_s3.c:916:SSL alert number 80","target":"vector::sinks::util::retries","span":{"request_id":21145,"name":"request"},"spans"[{"component_id":"vectorInput","component_kind":"sink","component_type":"opentelemetry","name":"sink"},{"request_id":21145,"name":"request"}]}

Steps to reproduce

Create vector input server instance (we use TOML), here is the snippet:

[sources.otlpSource]
  type = "opentelemetry"
  # Although grps is never used, it still must be specified in the TOML or else vector won't start
  [sources.otlpSource.grpc]
    address = "127.0.0.1:4317"

    [sources.otlpSource.grpc.tls]
      enabled            = true
      ca_file            = "ca.crt"
      crt_file           = "tls.crt"
      key_file           = "tls.key"
      verify_certificate = true
      verify_hostname    = false

  [sources.otlpSource.http]
    address = "0.0.0.0:4318"

    [sources.otlpSource.http.tls]
      enabled            = true
      ca_file            = "ca.crt"
      crt_file           = "tls.crt"
      key_file           = "tls.key"
      verify_certificate = true
      verify_hostname    = false

As this is partial config, you can use blackhole as a sink: https://vector.dev/docs/reference/configuration/sinks/blackhole/

Use openssl s_client directly against the created Vector instance a valid mTLS client certificate/key:

HOST=<the input hostname>
PORT=4318
CERT=client.crt
KEY=client.key
CA=ca.crt

# Step 1: fresh handshake, save the negotiated session
echo -e "GET / HTTP/1.0\r\n\r\n" | openssl s_client -connect ${HOST}:${PORT} \
  -cert $CERT -key $KEY -CAfile $CA \
  -sess_out /tmp/session.pem -quiet

# Step 2: attempt to resume the saved session against the same server
echo -e "GET / HTTP/1.0\r\n\r\n" | openssl s_client -connect ${HOST}:${PORT} \
  -cert $CERT -key $KEY -CAfile $CA \
  -sess_in /tmp/session.pem -quiet

Root cause

Thank to @cloudradar-net for root cause analysis, let me complement it a bit: Vector's shared TLS setup code: lib/vector-core/src/tls/settings.rs function apply_context_base configures the OpenSSL SslContextBuilder used by both TLS clients and TLS servers/sources.

This function:

  • calls set_verify(SslVerifyMode::PEER | SslVerifyMode::FAIL_IF_NO_PEER_CERT) when verify_certificate is enabled
  • never calls SSL_CTX_set_session_id_context for either the client or the server path.

As mentioned earlier: OpenSSL requires a session ID context to be set on any SSL_CTX that both (a) enables peer certificate verification (SSL_VERIFY_PEER) and (b) participates in session caching/resumption — without it, OpenSSL cannot safely determine that a resumed session was originally established with the same verified peer identity, and refuses the resumption with a fatal internal_error alert rather than risk resuming a session across different client identities.

Because Vector's shared TLS helper never sets this context, any Vector TLS server/source configured with verify_certificate: true will hit this failure whenever a client attempts to resume a previously-issued session.

Suggested fix

In apply_context_base (or the server-construction path that calls into it), call SslContextBuilder::set_session_id_context with a stable, unique identifier (e.g. derived from the listener/source's configured name or certificate) whenever verify_certificate is enabled on a TLS server/source. This is the standard OpenSSL-recommended pattern for servers that combine peer certificate verification with session resumption/caching.

DimDroll avatar Aug 28 '26 16:08 DimDroll

Still present in 0.60.0 (vector source + vector sink, mTLS with verify_certificate: true). Same reproduction: fresh TLS 1.2 handshake OK, openssl s_client -sess_in -> alert 80 immediately. From reading the code, nothing has changed here in v0.61.0 or on master: apply_context_base still sets PEER | FAIL_IF_NO_PEER_CERT and never calls set_session_id_context. On the client side, hyper-openssl's HttpsConnector caches sessions (SslSessionCacheMode::CLIENT) and offers them on every reconnect, so every reconnect of an idle sink first fails and is then retried. Side note: the acceptor uses mozilla_intermediate (v4), which also disables TLS 1.3.

christuser77 avatar Nov 08 '26 08:11 christuser77