Like you, I wanted to be able to install machine keys, but not pass them to web.config, which goes to the original control and becomes a security risk, and can use the same configuration system for each environment that we use with AppSettings . I found a solution for this, although it is a bit ugly as it uses reflection to manage the configuration MachineKeySection.
var getter = typeof(MachineKeySection).GetMethod("GetApplicationConfig", BindingFlags.Static | BindingFlags.NonPublic);
var config = (MachineKeySection)getter.Invoke(null, Array.Empty<object>());
var readOnlyField = typeof(ConfigurationElement).GetField("_bReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
readOnlyField.SetValue(config, false);
config.DecryptionKey = myKeys.EncryptionKey;
config.ValidationKey = myKeys.ValidationKey;
readOnlyField.SetValue(config, true);
, , , , . - , .
: https://gist.github.com/cmcnab/d2bbed02eb429098ed3656a0729ee40a