Good Afternoon,
I've been following the documentation for adding mutual TLS to Identity Server.
However, when I add the following code:
var builder = services.AddIdentityServer(options =>
{
options.MutualTls.Enabled = true;
options.MutualTls.ClientCertificateAuthenticationScheme = "x509";
});
I get this import reference error:
'Identity Server Options' does not contain a definition for 'MutualTls'...
It's the same for AddMutualTlsSecretValidators
.
Are those references in a separate library? I scoured the documentation and have been digging around for a while but can't seem to find anything.
Any help you can give will be greatly appreciated.
I tried various imports in my Startup class such as IdentityModel, idunno.Authentication.Certificate and IdentityServer4 but those didn't help.
Here's my Startup class:
using IdentityModel;
using idunno.Authentication.Certificate;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;
namespace IdentityServer
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddAuthentication()
.AddCertificate("x509", options =>
{
options.RevocationMode = System.Security.Cryptography.X509Certificates.X509RevocationMode.NoCheck;
options.Events = new CertificateAuthenticationEvents
{
OnValidateCertificate = context =>
{
context.Principal = Principal.CreateFromCertificate(context.ClientCertificate, includeAllClaims: true);
context.Success();
return Task.CompletedTask;
}
};
});
var builder = services.AddIdentityServer(options =>
{
// Complains about missing reference
options.MutualTls.Enabled = true;
// Complains about missing reference
options.MutualTls.ClientCertificateAuthenticationScheme = "x509";
})
.AddDeveloperSigningCredential()
.AddInMemoryIdentityResources(Config.GetIdentityResources())
.AddInMemoryApiResources(Config.GetApis())
.AddInMemoryClients(Config.GetClients())
.AddTestUsers(Config.GetUsers())
// Complains about missing reference
.AddMutualTlsSecretValidators();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseIdentityServer();
app.UseMvcWithDefaultRoute();
}
}
}
As Ruard van Elburg said, looks like my version of Identity Server 4 was not the most current. When I updated to the latest (2.5.0) it worked.