By the way
options.AddDevelopmentEncryptionAndSigningCertificate = true;
I also just try true, but i was false
public override void PreConfigureServices(ServiceConfigurationContext context) { //PaymentManagementDtoExtensions.Configure();
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
PreConfigure<OpenIddictBuilder>(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("PaymentManagement");
options.UseLocalServer();
options.UseAspNetCore();
});
});
if (!hostingEnvironment.IsDevelopment())
{
PreConfigure<AbpOpenIddictAspNetCoreOptions>(options =>
{
options.AddDevelopmentEncryptionAndSigningCertificate = true;
});
PreConfigure<OpenIddictServerBuilder>(serverBuilder =>
{
//serverBuilder.AddProductionEncryptionAndSigningCertificate("openiddict.pfx", "00000000 - 0000 - 0000 - 0000 - 000000000000");
serverBuilder.AddProductionEncryptionAndSigningCertificate("openiddict.pfx", "00000000-0000-0000-0000-000000000000");
});
}
}
I mean my our application do not use external auth server. As you see below picture we host auth server built-in.
I also achieve to write stdoutlogs
EVENTLOGS Application '/LM/W3SVC/2/ROOT' with physical root 'C:\inetpub\wwwroot\PayosGate\PayosGateApiV2' has exited from Program.Main with exit code = '1'. First 30KB characters of captured stdout and stderr logs: [09:35:33 INF] Starting PaymentManagement.HttpApi.Host.
Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.
Windows API call SHGetKnownFolderPath returned error code: 5. Windows system error message is: Erişim engellendi. Reported at line: 427.
My Code is :
public class PaymentManagementHttpApiHostModule : AbpModule
{ public override void PreConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration();
PreConfigure<OpenIddictBuilder>(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("PaymentManagement");
options.UseLocalServer();
options.UseAspNetCore();
});
});
if (!hostingEnvironment.IsDevelopment())
{
PreConfigure<AbpOpenIddictAspNetCoreOptions>(options =>
{
options.AddDevelopmentEncryptionAndSigningCertificate = false;
});
PreConfigure<OpenIddictServerBuilder>(serverBuilder =>
{
serverBuilder.AddProductionEncryptionAndSigningCertificate("openiddict.pfx", "00000000-0000-0000-0000-000000000000");
serverBuilder.SetIssuer(new Uri(configuration["AuthServer:Authority"]!));
});
}
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
if (!configuration.GetValue<bool>("App:DisablePII"))
{
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
}
if (!configuration.GetValue<bool>("AuthServer:RequireHttpsMetadata"))
{
Configure<OpenIddictServerAspNetCoreOptions>(options =>
{
options.DisableTransportSecurityRequirement = true;
});
}
ConfigureAuthentication(context);
ConfigureUrls(configuration);
ConfigureBundles();
ConfigureConventionalControllers();
ConfigureExternalProviders(context);
ConfigureImpersonation(context, configuration);
ConfigureHealthChecks(context);
ConfigureSwagger(context, configuration);
ConfigureVirtualFileSystem(context);
ConfigureCors(context, configuration);
ConfigureTheme();
ConfigureHangfire(context, configuration);
}
private void ConfigureTheme()
{
Configure<LeptonXThemeOptions>(options =>
{
options.DefaultStyle = LeptonXStyleNames.System;
});
}
private void ConfigureAuthentication(ServiceConfigurationContext context)
{
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
{
options.IsDynamicClaimsEnabled = true;
});
}
private void ConfigureUrls(IConfiguration configuration)
{
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
options.Applications["Angular"].RootUrl = configuration["App:AngularUrl"];
options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password";
options.Applications["Angular"].Urls[AccountUrlNames.EmailConfirmation] = "account/email-confirmation";
options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"]?.Split(',') ?? Array.Empty<string>());
});
}
private void ConfigureBundles()
{
Configure<AbpBundlingOptions>(options =>
{
options.StyleBundles.Configure(
LeptonXThemeBundles.Styles.Global,
bundle =>
{
bundle.AddFiles("/global-styles.css");
}
);
});
}
private void ConfigureVirtualFileSystem(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
if (hostingEnvironment.IsDevelopment())
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.ReplaceEmbeddedByPhysical<PaymentManagementDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}PaymentManagement.Domain.Shared"));
options.FileSets.ReplaceEmbeddedByPhysical<PaymentManagementDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}PaymentManagement.Domain"));
options.FileSets.ReplaceEmbeddedByPhysical<PaymentManagementApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}PaymentManagement.Application.Contracts"));
options.FileSets.ReplaceEmbeddedByPhysical<PaymentManagementApplicationModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}PaymentManagement.Application"));
});
}
}
private void ConfigureConventionalControllers()
{
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(PaymentManagementApplicationModule).Assembly);
});
}
private static void ConfigureSwagger(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddAbpSwaggerGenWithOidc(
configuration["AuthServer:Authority"]!,
["PaymentManagement"],
[AbpSwaggerOidcFlows.AuthorizationCode],
null,
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "PaymentManagement API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
options.HideAbpEndpoints();
});
}
private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]?
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray() ?? Array.Empty<string>()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
}
private void ConfigureExternalProviders(ServiceConfigurationContext context)
{
context.Services.AddAuthentication()
.AddGoogle(GoogleDefaults.AuthenticationScheme, options =>
{
options.ClaimActions.MapJsonKey(AbpClaimTypes.Picture, "picture");
})
.WithDynamicOptions<GoogleOptions, GoogleHandler>(
GoogleDefaults.AuthenticationScheme,
options =>
{
options.WithProperty(x => x.ClientId);
options.WithProperty(x => x.ClientSecret, isSecret: true);
}
)
.AddMicrosoftAccount(MicrosoftAccountDefaults.AuthenticationScheme, options =>
{
//Personal Microsoft accounts as an example.
options.AuthorizationEndpoint = "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize";
options.TokenEndpoint = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token";
options.ClaimActions.MapCustomJson("picture", _ => "https://graph.microsoft.com/v1.0/me/photo/$value");
options.SaveTokens = true;
})
.WithDynamicOptions<MicrosoftAccountOptions, MicrosoftAccountHandler>(
MicrosoftAccountDefaults.AuthenticationScheme,
options =>
{
options.WithProperty(x => x.ClientId);
options.WithProperty(x => x.ClientSecret, isSecret: true);
}
)
.AddTwitter(TwitterDefaults.AuthenticationScheme, options =>
{
options.ClaimActions.MapJsonKey(AbpClaimTypes.Picture, "profile_image_url_https");
options.RetrieveUserDetails = true;
})
.WithDynamicOptions<TwitterOptions, TwitterHandler>(
TwitterDefaults.AuthenticationScheme,
options =>
{
options.WithProperty(x => x.ConsumerKey);
options.WithProperty(x => x.ConsumerSecret, isSecret: true);
}
);
}
private void ConfigureImpersonation(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.Configure<AbpAccountOptions>(options =>
{
options.TenantAdminUserName = "admin";
options.ImpersonationTenantPermission = SaasHostPermissions.Tenants.Impersonation;
options.ImpersonationUserPermission = IdentityPermissions.Users.Impersonation;
});
}
private void ConfigureHealthChecks(ServiceConfigurationContext context)
{
context.Services.AddPaymentManagementHealthChecks();
}
private void ConfigureHangfire(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddHangfire(config =>
{
config.UseSqlServerStorage(configuration.GetConnectionString("Default"));
});
//context.Services.AddHangfireServer();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseAbpRequestLocalization();
if (!env.IsDevelopment())
{
app.UseErrorPage();
}
app.UseStaticFiles();
app.UseAbpStudioLink();
app.UseRouting();
app.UseAbpSecurityHeaders();
app.UseCors();
app.UseAuthentication();
app.UseAbpOpenIddictValidation();
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
app.UseUnitOfWork();
app.UseDynamicClaims();
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "PaymentManagement API");
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseAbpHangfireDashboard();
app.UseConfiguredEndpoints();
}
}
We also use auth-server.pfx not openiddict.pfx. But there is some confusion. Is that can cause the issue?
Can you connect my desktop again?
I remove the web site folder and I applied the password 00000000-0000-0000-0000-000000000000 but I got the same error.
PS C:\inetpub\wwwroot\PayosGate\PayosGateApi> dotnet dev-certs https -v -ep openiddict.pfx -p 00000000-0000-0000-0000-000000000000 [1] Listing certificates from CurrentUser\My [2] Found certificates: 1 certificate 1) 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true [3] Checking certificates validity [4] Valid certificates: 1 certificate 1) 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true [5] Invalid certificates: no certificates [6] Finished listing certificates. [1] Listing certificates from LocalMachine\My [2] Found certificates: no certificates [3] Checking certificates validity [4] Valid certificates: no certificates [5] Invalid certificates: no certificates [6] Finished listing certificates. [8] Filtered certificates: 1 certificate 1) 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true [9] Excluded certificates: no certificates [14] Valid certificates: 1 certificate 1) 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true [15] Selected certificate: 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true [23] Saving certificate '193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true' to openiddict.pfx with private key. [27] Writing the certificate to: openiddict.pfx. A valid HTTPS certificate is already present. The certificate was exported to C:\inetpub\wwwroot\PayosGate\PayosGateApi\openiddict.pfx PS C:\inetpub\wwwroot\PayosGate\PayosGateApi> dotnet .\PaymentManagement.hTTPAPI.HOST.DLL [13:55:57 INF] Starting PaymentManagement.HttpApi.Host. PS C:\inetpub\wwwroot\PayosGate\PayosGateApi>
dotnet dev-certs https -v -ep openiddict.pfx -p 00000000-0000-0000-0000-000000000000
[1] Listing certificates from CurrentUser\My
[2] Found certificates: 1 certificate
1) 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
[3] Checking certificates validity
[4] Valid certificates: 1 certificate
1) 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
[5] Invalid certificates: no certificates
[6] Finished listing certificates.
[1] Listing certificates from LocalMachine\My
[2] Found certificates: 1 certificate
1) 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
[3] Checking certificates validity
[4] Valid certificates: 1 certificate
1) 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
[5] Invalid certificates: no certificates
[6] Finished listing certificates.
[8] Filtered certificates: 2 certificates
1) 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
2) 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
[9] Excluded certificates: no certificates
[14] Valid certificates: 2 certificates
1) 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
2) 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
[15] Selected certificate: 193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
[23] Saving certificate '193B08B2C754BE796AFE64856FE863FD339EB078 - CN=localhost - Valid from 2024-05-15 00:07:34Z to 2025-05-15 00:07:34Z - IsHttpsDevelopmentCertificate: true - IsExportable: true' to openiddict.pfx with private key.
[27] Writing the certificate to: openiddict.pfx.
A valid HTTPS certificate is already present.
The certificate was exported to C:\inetpub\wwwroot\PayosGate\PayosGateApi\openiddict.pfx
PS C:\inetpub\wwwroot\PayosGate\PayosGateApi> dotnet .\PaymentManagement.hTTPAPI.HOST.DLL
[12:44:30 INF] Starting PaymentManagement.HttpApi.Host.
[12:44:31 FTL] Host terminated unexpectedly!
Volo.Abp.AbpInitializationException: An error occurred during ConfigureServicesAsync phase of the module Volo.Abp.OpenIddict.AbpOpenIddictAspNetCoreModule, Volo.Abp.OpenIddict.AspNetCore, Version=8.3.0.0, Culture=neutral, PublicKeyToken=null. See the inner exception for details.
---> System.Security.Cryptography.CryptographicException: The specified network password is not correct.
at System.Security.Cryptography.X509Certificates.CertificatePal.FilterPFXStore(ReadOnlySpan`1 rawData, SafePasswordHandle password, PfxCertStoreFlags pfxCertStoreFlags)
at System.Security.Cryptography.X509Certificates.CertificatePal.FromBlobOrFile(ReadOnlySpan`1 rawData, String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)
at Microsoft.Extensions.DependencyInjection.OpenIddictServerBuilderExtensions.AddProductionEncryptionAndSigningCertificate(OpenIddictServerBuilder builder, String fileName, String passPhrase)
at PaymentManagement.PaymentManagementApplicationContractsModule.<>c.<PreConfigureServices>b__0_2(OpenIddictServerBuilder serverBuilder) in C:\work\PayosGate\PaymentManagement\src\PaymentManagement.Application.Contracts\PaymentManagementApplicationContractsModule.cs:line 67
at Volo.Abp.Options.PreConfigureActionList`1.Configure(TOptions options)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionPreConfigureExtensions.ExecutePreConfiguredActions[TOptions](IServiceCollection services, TOptions options)
at Volo.Abp.OpenIddict.AbpOpenIddictAspNetCoreModule.<>c__DisplayClass1_0.<AddOpenIddictServer>b__0(OpenIddictServerBuilder builder)
at Microsoft.Extensions.DependencyInjection.OpenIddictServerExtensions.AddServer(OpenIddictBuilder builder, Action`1 configuration)
at Volo.Abp.OpenIddict.AbpOpenIddictAspNetCoreModule.AddOpenIddictServer(IServiceCollection services)
at Volo.Abp.OpenIddict.AbpOpenIddictAspNetCoreModule.ConfigureServices(ServiceConfigurationContext context)
at Volo.Abp.Modularity.AbpModule.ConfigureServicesAsync(ServiceConfigurationContext context)
at Volo.Abp.AbpApplicationBase.ConfigureServicesAsync()
--- End of inner exception stack trace ---
at Volo.Abp.AbpApplicationBase.ConfigureServicesAsync()
at Volo.Abp.AbpApplicationFactory.CreateAsync[TStartupModule](IServiceCollection services, Action`1 optionsAction)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionApplicationExtensions.AddApplicationAsync[TStartupModule](IServiceCollection services, Action`1 optionsAction)
at Microsoft.Extensions.DependencyInjection.WebApplicationBuilderExtensions.AddApplicationAsync[TStartupModule](WebApplicationBuilder builder, Action`1 optionsAction)
at PaymentManagement.Program.Main(String[] args) in C:\work\PayosGate\PaymentManagement\src\PaymentManagement.HttpApi.Host\Program.cs:line 36
PS C:\inetpub\wwwroot\PayosGate\PayosGateApi>
I am waiting for your accept
Do you have any desk
First we can make a teams call : https://teams.live.com/meet/9451437043424?p=xV325AFhbbWlwpTvlb
If you want I can send you an invitation, send me your id. Your request has not reach to me
It does not work. Can you connect my desktop,
AnyDesk Code : 1 867 337 541