Skip to content

[BUG]: Can't provide my own rootCert.pfx #1410

@rubin55

Description

@rubin55

Description

I was hoping that I should be able to do more or less the following:

openssl req -subj "/CN=Dev Proxy CA" -nodes -x509 -sha256 -days 1825 -newkey rsa:2048 -keyout "ca.key.pem" -out "ca.crt.pem"
openssl pkcs12 -export -out ~/.config/dev-proxy/rootCert.pfx -inkey ca.key.pem -in ca.crt.pem -macalg SHA1 -iter 2000 -maciter -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES

I.e., instead of using a rootCert generated by devproxy on first run, I pre-create rootCert.pfx and place it in the expected location. Sure enough, devproxy starts without errors (even with Trace log level by the way). But! When I try to do any HTTPS call, I get the following:

$ curl -v https://localhost:3002/health
* Uses proxy env variable no_proxy == 'localhost:8006'
* Uses proxy env variable https_proxy == 'http://localhost:8000'
* Host localhost:8000 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:8000...
* connect to ::1 port 8000 from ::1 port 38158 failed: Connection refused
*   Trying 127.0.0.1:8000...
* CONNECT: no ALPN negotiated
* allocate connect buffer
* Establish HTTP proxy tunnel to localhost:3002
> CONNECT localhost:3002 HTTP/1.1
> Host: localhost:3002
> User-Agent: curl/8.16.0
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection Established
< Content-Length: 0
* Ignoring Content-Length in CONNECT 200 response
<
* CONNECT phase completed
* CONNECT tunnel established, response 200
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: none
* TLSv1.3 (OUT), TLS alert, decode error (562):
* TLS connect error: error:0A000126:SSL routines::unexpected eof while reading
* closing connection #0
curl: (35) TLS connect error: error:0A000126:SSL routines::unexpected eof while reading

What I would like to know:

  • Why can't devproxy start with a provided rootCert.pfx?
  • Why doesn't devproxy log clearly that it can't use the cert, or what it expects?
  • Can you glean from the above openssl commands why it wouldn't work? Also see attached here the unencrypted dumps original.txt, which is output from a by-devproxy-generated rootCert.pfx and custom.txt, which is the rootCert.pfx generated by the above commands.

Expected behaviour

I expect to be able to provide my own rootCert.pfx, or at least to get clear logging about what is wrong with a provided certificate.

Actual behaviour

devproxy fails silently.

Steps to reproduce

  1. Place your own rootCert.pfx
  2. Start devproxy
  3. Do a call to an HTTPS url
  4. Observe unexpected eof while reading

Dev Proxy Version

1.2.0

Operating system (environment)

Linux

Shell

bash

Configuration file

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.2.0/rc.schema.json",
  "plugins": [
    {
      "enabled": true,
      "name": "OpenApiSpecGeneratorPlugin",
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "specFormat": "Yaml",
      "specVersion": "v3_0"
    }
  ],
  "languageModel": {
    "enabled": true,
    "model": "qwen3-coder"
  },
  "logLevel": "debug",
  "newVersionNotification": "stable",
  "showSkipMessages": true,
  "showTimestamps": true,
  "validateSchemas": true,
  "urlsToWatch": [
    "*"
  ]
}

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions