# Fails on invalid TLS key

cert $WORK karma
exec karma --pid-file=karma.pid --config.file=karma.yaml --listen.address=127.0.0.1 --listen.port=8088
! stdout .
cmp stderr stderr.txt

-- server.bad --
BAD KEY
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" cluster=local name=local proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=local
level=info msg="GET request" timeout=10 uri=https://127.0.0.1:9093/metrics
level=error msg="Request failed" error="Get \"https://127.0.0.1:9093/metrics\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local uri=https://127.0.0.1:9093
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/silences\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=1/2
level=info msg="GET request" timeout=10 uri=https://127.0.0.1:9093/metrics
level=error msg="Request failed" error="Get \"https://127.0.0.1:9093/metrics\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local uri=https://127.0.0.1:9093
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/silences\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTPS server" address=127.0.0.1:8088
level=error msg="HTTPS server startup error" error="tls: failed to find any PEM data in key input"
level=info msg="Shutting down HTTP server" signal=terminated
level=info msg="HTTP server shut down"
level=info msg="Removing PID file" path=karma.pid
-- karma.yaml --
alertmanager:
  servers:
    - name: local
      uri: https://127.0.0.1:9093
      timeout: 10s
listen:
  tls:
    cert: karma.pem
    key: server.bad
