runtime: `CertificateRequest.CreateSelfSigned` fails on macOS Sequoia
Update: repro app here
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
the command dotnet dev-certs https fails with the error:
There was an error creating the HTTPS developer certificate.
Exception:
An error has occurred generating the certificate: Interop+AppleCrypto+AppleCommonCryptoCryptographicException: The specified item is no longer valid. It may have been deleted from the keychain.
at Interop.AppleCrypto.X509CopyWithPrivateKey(SafeSecCertificateHandle certHandle, SafeSecKeyRefHandle privateKeyHandle, SafeKeychainHandle targetKeychain)
at System.Security.Cryptography.X509Certificates.AppleCertificatePal.CopyWithPrivateKey(SafeSecKeyRefHandle privateKey)
at System.Security.Cryptography.X509Certificates.AppleCertificatePal.CopyWithPrivateKey(RSA privateKey)
at System.Security.Cryptography.X509Certificates.RSACertificateExtensions.CopyWithPrivateKey(X509Certificate2 certificate, RSA privateKey)
at System.Security.Cryptography.X509Certificates.CertificateRequest.CreateSelfSigned(DateTimeOffset notBefore, DateTimeOffset notAfter)
at Microsoft.AspNetCore.Certificates.Generation.CertificateManager.CreateSelfSignedCertificate(X500DistinguishedName subject, IEnumerable`1 extensions, DateTimeOffset notBefore, DateTimeOffset notAfter)
at Microsoft.AspNetCore.Certificates.Generation.CertificateManager.CreateAspNetCoreHttpsDevelopmentCertificate(DateTimeOffset notBefore, DateTimeOffset notAfter)
at Microsoft.AspNetCore.Certificates.Generation.CertificateManager.EnsureAspNetCoreHttpsDevelopmentCertificate(DateTimeOffset notBefore, DateTimeOffset notAfter, String path, Boolean trust, Boolean includePrivateKey, String password, CertificateKeyExportFormat keyExportFormat, Boolean isInteractive).
What I already tried:
dotnet dev-certs https --clean- installing the lastest dotnet version
- uninstalling all old dotnet versions
- reinstalling dotnet completely
- restarting the Terminal, reboot, etc.
Nothing changed the behaviour and i still get the same error.
Expected Behavior
the certificate should be created.
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
8.0.401
Anything else?
dotnet --info
.NET SDK:
Version: 8.0.401
Commit: 811edcc344
Workload version: 8.0.400-manifests.56cd0383
MSBuild version: 17.11.4+37eb419ad
Runtime Environment:
OS Name: Mac OS X
OS Version: 15.0
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/8.0.401/
.NET workloads installed:
Configured to use loose manifests when installing new manifests.
[wasm-tools]
Installation Source: SDK 8.0.400
Manifest Version: 8.0.8/8.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.workload.mono.toolchain.current/8.0.8/WorkloadManifest.json
Install Type: FileBased
[wasi-experimental]
Installation Source: SDK 8.0.400
Manifest Version: 8.0.8/8.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.workload.mono.toolchain.current/8.0.8/WorkloadManifest.json
Install Type: FileBased
[ios]
Installation Source: SDK 8.0.400
Manifest Version: 17.5.8020/8.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.ios/17.5.8020/WorkloadManifest.json
Install Type: FileBased
[maccatalyst]
Installation Source: SDK 8.0.400
Manifest Version: 17.5.8020/8.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maccatalyst/17.5.8020/WorkloadManifest.json
Install Type: FileBased
Host:
Version: 8.0.8
Architecture: arm64
Commit: 08338fcaa5
.NET SDKs installed:
8.0.401 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
x64 [/usr/local/share/dotnet/x64]
registered at [/etc/dotnet/install_location_x64]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 44 (19 by maintainers)
@kalebzettl @pvasek Thanks, that worked for me. Here’s a consolidated instruction set:
Just in case, delete any certs that currently exist. Open a terminal and run:
dotnet dev-certs https --cleanDownload the
tar.gzfile of the “main” release from the .NET SDK package table. You can also access the links directly below.Unpack the downloaded file.
Remove the quarantine attribute from the unpacked folder. From your terminal run:
xattr -d com.apple.quarantine -r <folderName>Replace<folderName>with the name of your unpacked folder. For example:xattr -d com.apple.quarantine -r dotnet-sdk-9.0.100-rc.2.24473.22-osx-arm64Navigate to the unpacked folder:
cd dotnet-sdk-9.0.100-rc.2.24473.22-osx-arm64From within this folder, run the following to generate and trust the certificate.
./dotnet dev-certs https --trustSo all the users of the modern Mac OS is blocked from using .net and you just tell to wait for the October release? Guys, it looks like a critical issue and the fix should be deployed in hours, not even days…
Workaround that worked for me:
./dotnet dev-certs https --trust(it’s important to use./otherwise it use the installeddotnet)After that it ask for password install the certificate and debugging of my 8.0 app works again.
@pvasek Thank you mate, that worked for me too, only thing I had to quarantine the folder, I have SIP enabled and all macOS wanted to do was complain about it being untrusted 🙄
xattr -d com.apple.quarantine -r dotnet-sdk-9.0.100-rc.2.24473.20-osx-arm64 cd dotnet-sdk-9.0.100-rc.2.24473.20-osx-arm64 ./dotnet dev-certs https --trust
This shouldn’t be closed until there is a release out the door. And someone internal should be making the call to release an emergency patch release .402 that fixes this.
I’m getting the same thing. Same exact output.
Thanks for your prompt reply!
dotnet dev-certs https --clean --verboseoutputs:and
dotnet dev-certs https --verboseoutputs:Agreed. Otherwise pointing to some documented steps on how to manually generate the certification and import it using the dotnet CLI would be better than a “wait until the October update train” hand-waive.
We don’t all have the luxury of not upgrading to Apple’s latest OS because we’re not all just dotnet developers.
.NET 8.0.10 is already available and feels like it contains the fix.
I’m on MacOS Sequoia (15.0 Beta 24A5327a).
Just ran the sample console app and get the same exception as in the dotnet tool:
Okay, curiosity took over so I had a peek.
The “good news” is that our unit tests fail and reproduce the issue:
The other “good news” is that this is the only thing that fails on macOS 15.
That’s actually good news because it means they haven’t decided they don’t like the slightly unusual shape of our certificate.
ok, for anyone that hits this:
dotnet dev-certs https --clean dotnet dev-certs https --trust
Will work if it doesn’t just work automatically.
Thanks @vcsjones for the clean suggestion.
PS: MS Mac fix for Sequoia should be in the release notes and called out exactly how to fix this.
I was not able to reproduce this with Sequoia and .NET 8.0.10.
Can you please be more specific about the error you are getting, steps to reproduce, and the output of
dotnet --info?It doesn’t fix it.
This is still broken. Not sure how this isn’t resolved yet. Entire platform completely broken without hacking with pre-release software.
it helps me to run webapp (but I had to add config in the Program.cs) but I still can’t make requests from android emulator. I am shocked that this issue was closed and that’s it, wait until November
Dont think its the best but it works for the time being. Generating a self signed crt + key, convert it to a pfx and then configure the app to use that
appsettings.Development.json
At least i can now continue development.
Any update or workaround here? Our team is blocked because of this. Should we just reinstall the old version of Mac OS just to have this command work?
dotnet dev-certs https --trustI don’t know when we’re going to have a chance to look at this (not “indefinitely far”, but probably “at least several days away”). We have a few small fires to deal with for the .NET 9 release on already in-market OSes, and are super-saturated on those tasks.
If anyone from the community at large wants to jump in and help debug what’s going on, that’d be appreciated.
Moving this to
dotnet/runtimenow that there’s a repro not involving aspnetcore.same exception unfortunately.
I am on Sequoia. Beta 7.