Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 16, 2025

Unobtanium.Web.Proxy's internal logs (certificate loading, proxy lifecycle) were invisible because ProxyServer was instantiated without a LoggerFactory. This made debugging certificate and proxy initialization issues difficult.

Changes

  • ProxyEngine: Inject ILoggerFactory and pass to ProxyServer constructor via new EnsureProxyServerInitialized() method

    • Thread-safe lazy initialization replaces static constructor initialization
    • ProxyServer remains static for backward compatibility with existing callers
  • CertCommand & ProxyController: Inject ILoggerFactory and call EnsureProxyServerInitialized() before accessing ProxyServer

Unobtanium's internal logs now appear at --log-level Trace:

trce    CertificateManager: LoadOrCreateRootCertificateAsync(True) called
trce    CertificateManager: LoadRootCertificate() called
trce    CertificateManager: Root certificate loaded from file
trce    ProxyServer: StartAsync(changeSystemProxySettings: True) called

Fixes #1410

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net9.0/devproxy --help (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net9.0/devproxy --log-level Debug --urls-to-watch REDACTED* (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net9.0/devproxy cert ensure --log-level Trace (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Log messages from Unobtanium</issue_title>
<issue_description>> > Here's the point in code where it's loading the certificate: https://github.com/svrooij/unobtanium-web-proxy/blob/5a6d45bcebb55c8e85b75bddc7ffe7f7ebd69d76/src/Unobtanium.Web.Proxy/Certificates/CertificateManager.cs#L609.

I see log calls in that code; can I somehow set a setting, or environment variable that make those log messages appear?

At the moment, the only way would be to update how we instantiate the ProxyServer here:

ProxyServer = new();
and pass the LoggerFactory to the constructor. You'd need to update the code and build Dev Proxy yourself. We're not doing this at the moment in our code at the moment. Sorry for the trouble.

Originally posted by @waldekmastykarz in #1410

We need to ensure that these message are properly displayed in Dev Proxy output. They should be attached to Debug and Trace log levels in Dev Proxy.</issue_description>

<agent_instructions>Pass Dev Proxy LoggerFactory to the constructor. Verify that logging statements from Unobtanium are displayed consistently with other Dev Proxy debug- and trace-level logs.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copilot AI changed the title [WIP] Add logger factory to ProxyServer instantiation Pass ILoggerFactory to Unobtanium ProxyServer for internal logging Nov 16, 2025
Copilot finished work on behalf of waldekmastykarz November 16, 2025 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Log messages from Unobtanium [BUG]: Can't provide my own rootCert.pfx

2 participants