Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

SMTP Settings - Decrypt question #6206


User avatar
0
exlnt created

I have implemented SendGrid for emails into my AZN V6.3 solution. I am storing my SendGrid API key value in the SMTP settings. In the host settings app service when the password value is saved, it uses the encrypt code shown below. await SettingManager.ChangeSettingForApplicationAsync(EmailSettingNames.Smtp.Password, SimpleStringCipher.Instance.Encrypt(settings.SmtpPassword))

So naturally when I try to retrieve this password for my SendGrid send email method, I use decrypt code, shown below. var apikey = await _settingManager.GetSettingValueForApplicationAsync(SimpleStringCipher.Instance.Decrypt(EmailSettingNames.Smtp.Password));

However when this code executes, it throws this error: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

The SendGrid API key does contain a . and _ is 69 characters long.

I did find some solutions on stackoverflow. However I cannot apply the "replace" option here, as the password is generated and provided by SendGrid.

Do I have any other options to be able to decrypt this type of password with AZN code? For now, I have just hard-coded the API key.


1 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Decrypt the setting, not the setting name.

    var apikey = SimpleStringCipher.Instance.Decrypt(await _settingManager.GetSettingValueForApplicationAsync(EmailSettingNames.Smtp.Password));