Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IConfigurationSection non può essere null #85

Open
pampua84 opened this issue Jan 27, 2025 · 0 comments
Open

IConfigurationSection non può essere null #85

pampua84 opened this issue Jan 27, 2025 · 0 comments

Comments

@pampua84
Copy link

Describe the bug
Sto provando a caricare un certificato da una configurazione custom nella classe CustomSpidEvents.cs come suggerito nella documentazione, quindi non fornisco nessuna sezione Certificate nell'appsettings. Il problema è che nella classe OptionsHelper.cs viene eseguito il seguente codice:

 IConfigurationSection section3 = section1.GetSection("Certificate");
  if (section3 != null)
  {
	string str = section3.GetValue<string>("Source");
	if (str.Equals("Store", StringComparison.OrdinalIgnoreCase))
	{
             .......
        }

Ma section3 non può essere null in quanto GetSection non torna mai null come indicato nella documentazione Microsoft

This method will never return null. If no matching sub-section is found with the specified key, an empty

Il metodo GetValue<string> invece torna null e quindi sul metodo Equals viene sollevata una NullReferenceException:

System.NullReferenceException: Object reference not set to an instance of an object.
at SPID.AspNetCore.Authentication.Helpers.OptionsHelper.CreateFromConfiguration(IConfiguration configuration)
at SPID.AspNetCore.Authentication.Models.SpidOptions.LoadFromConfiguration(IConfiguration configuration)

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

No branches or pull requests

1 participant