in src/Microsoft.ServiceFabric.AspNetCore.Configuration/ServiceFabricConfigurationOptions.cs [111:136]
internal string DefaultExtractValueFunc(FabricConfigurationSection section, ConfigurationProperty property)
{
// see https://github.com/Azure/service-fabric-aspnetcore/issues/9
// A typical safety guideline is to keep encrypted string encrypted in memory, and then decrypt (briefly) at time of use.
// With this reason, will treat encrypted value the same as plain text by default,
// user will need to handle encrypted string separately to compliant with security best practice.
if (property.IsEncrypted && this.DecryptValue)
{
IntPtr unmanagedString = IntPtr.Zero;
var secureString = property.DecryptValue();
try
{
unmanagedString = Marshal.SecureStringToGlobalAllocUnicode(secureString);
return Marshal.PtrToStringUni(unmanagedString);
}
finally
{
Marshal.ZeroFreeGlobalAllocUnicode(unmanagedString);
}
}
else
{
return property.Value;
}
}