SslStream.AuthenticateAsClient() is popping up a challenge for the system keychain on MacOS
Description
For some reason, SslStream.AuthenticateAsClient() is trying to modify the system keychain on MacOS, and if it doesn't have permission, it is popping up a UI to get an userid/password that does have permission.
Screenshot of the UI:
Reproduction Steps
Call SslStream.AuthenticateAsClient() on MacOS sw_vers 13.6.3 (doesn't appear to happen on 13.6).
Expected behavior
Do SSL handshake.
Actual behavior
See popup above.
Regression?
Yes.
Known Workarounds
None.
Configuration
Have tried .NET 6 and .NET 8 and both exhibit the problem, along with MacOS 13.6.3+.
Other information
No response
Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones See info in area-owners.md if you want to be subscribed.
Issue Details
Description
For some reason, SslStream.AuthenticateAsClient() is trying to modify the system keychain on MacOS, and if it doesn't have permission, it is popping up a UI to get an userid/password that does have permission.
Screenshot of the UI:
Reproduction Steps
Call SslStream.AuthenticateAsClient() on MacOS sw_vers 13.6.3 (doesn't appear to happen on 13.6).
Expected behavior
Do SSL handshake.
Actual behavior
See popup above.
Regression?
Yes.
Known Workarounds
None.
Configuration
Have tried .NET 6 and .NET 8 and both exhibit the problem, along with MacOS 13.6.3+.
Other information
No response
| Author: | ScotMac |
|---|---|
| Assignees: | - |
| Labels: |
|
| Milestone: | - |
I cannot reproduce this on .NET 6, 8, or 9-preview1 on macOS 14.3.1. Here is the code I used.
using System;
using System.Net;
using System.Net.Sockets;
using System.Net.Security;
using TcpClient tcpClient = new();
await tcpClient.ConnectAsync("github.com", 443);
using SslStream ssl = new(tcpClient.GetStream());
SslClientAuthenticationOptions options = new() {
TargetHost = "github.com",
};
await ssl.AuthenticateAsClientAsync(options);
Console.WriteLine("Okay all done: cert: " + ssl.RemoteCertificate.Subject);
- Can you share the code you used to reproduce the issue?
- If you have access to more than one Mac, does this reproduce for you with other Macs?
This issue has been marked needs-author-action and may be missing some important information.
You must be logged into the console for it to happen, since the popup UI is relying on the base MacOS GUI.
You must be logged into the console for it to happen
Can you explain? I was logged in to my Mac when I tried to reproduce this. I was not remotely connected. I used the code above from a Console application from Terminal, and did not see any keychain popups.
Also, your AuthenticateAsClient is very different from mine:
m_sslstream = new SslStream(m_client.GetStream(), false, this.ValidateRemoteCertificate, null);
m_sslstream.AuthenticateAsClient(!string.IsNullOrEmpty(conOption.Hostname) ? conOption.Hostname :
(conOption.Host == null ? "" : conOption.Host), new X509Certificate2Collection { x509 }, SSLProtocol, false);
@vcsjones The x509Certificate2Collection ( "new X509Certificate2Collection { x509 }") is just a public cert that is associated with our list of trusted CAs.
Do you have other machines where you can try to reproduce this problem?
Also, it would be great if you provided us a fully self-contained repro project if you feel like there is some specific setup needed. Otherwise it is hard to guess what is happening.
Since there has been no recent activity from the reporter, I am closing this now since this is not reproducible/actionable for us at the moment. If the issue resurfaces, feel free to comment or open a new issue with more details or ideally with a small program which reproduces the issue.