2015-10-20 3 views
2

Я успешно отправляю EMail с помощью Amazon-SES в течение многих лет. Однако, по причинам соблюдения PCI, мы пытаемся отключить TLS 1.0:Как включить TLS 1.1/1.2 для Amazon Simple Email Service

System.Net.ServicePointManager.SecurityProtocol = 
    SecurityProtocolType.Tls11 | 
    SecurityProtocolType.Tls12; 

Однако, это вызывает исключение при попытке отправить сообщение:

AuthenticationException: 
    A call to SSPI failed, see inner exception. 
    The client and server cannot communicate, because they do not 
    possess a common algorithm 

Как только я добавляю SecurityProtocolType.Tls назад in, это снова удается. Случается как с .NET 4.5, так и с 4.6. Использование AWSSDK-SimpleEmail (v3.1.1.1) & AWSSDK-Core Runtime (v3.1.2.1)

+0

Дикий удар: что произойдет, если вы настроите только 1.1 или 1.2, не оба? –

+0

Хорошая мысль, но к сожалению нет - только SecurityProtocolType.Tls, похоже, работает. – AcidPAT

+0

Сегодня я столкнулся с той же проблемой, вызванной в моем случае обновлением до последней версии SDK PayPal, которая, похоже, отключает поддержку TLS v1.0 в приложении .NET (таким образом, что это влияет на другие SDK). Я поднял его на форуме AWS SES, который, я надеюсь, является хорошим местом, чтобы спросить и получить официальный ответ от AWS. https://forums.aws.amazon.com/thread.jspa?threadID=221748 –

ответ

2

Ответ мой собственный вопрос:
Мы оставили TLS включен 1,0 Client и TLS 1.0 SERVER отключен. Это сделало SSLLabs и PCI проверенными, но при этом мы можем подключиться к SAS Amazon для отправки электронной почты. Вот код, который мы используем:

private static Tuple<string, string, bool>[] s_ProtocolConfig = 
    { 
     Tuple.Create("SSL 2.0", "client", false), 
     Tuple.Create("SSL 2.0", "server", false), 
     Tuple.Create("SSL 3.0", "client", false), 
     Tuple.Create("SSL 3.0", "server", false), 
     Tuple.Create("TLS 1.0", "client", true), // Leave this to TRUE, so that we can send outgoing email. 
     Tuple.Create("TLS 1.0", "server", false), // Change this to disable incoming 1.0 TLS requests 
     Tuple.Create("TLS 1.1", "client", true), 
     Tuple.Create("TLS 1.1", "server", true), 
     Tuple.Create("TLS 1.2", "client", true), 
     Tuple.Create("TLS 1.2", "server", true), 
    }; 

    /// <summary> 
    /// Disable/Enable Protocole 
    /// require a reboot if the values are changed. 
    /// </summary> 
    private static bool ConfigureProtocols(IEnumerable<Tuple<string, string, bool>> config) 
    { 
     bool rebootRequired = false; 
     using (RegistryKey protocols = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols", true)) 
     { 
      foreach (Tuple<string, string, bool> proto in config) 
      { 
       string protocol = proto.Item1; 
       string clientServer = proto.Item2; 
       bool enabled = proto.Item3; 

       using (RegistryKey group = protocols.CreateSubKey(protocol)) 
       { 
        bool added = group.OpenSubKey(clientServer) == null; 

        using (RegistryKey newKey = group.CreateSubKey(clientServer)) 
        { 
         bool updated = EnsureValue(newKey, "disabledbydefault", !enabled); 
         updated |= EnsureValue(newKey, "enabled", enabled); 
         newKey.Close(); 

         if (!added && updated) 
         { 
          // the values have changed. Reboot is required to have them be reflected 
          rebootRequired = true; 
         } 
         if (added && !enabled) 
         { 
          // lack of added key is the same as enabled. 
          // therefore was enabled, but we need disabled = reboot required 
          rebootRequired = true; 
         } 
        } 
        group.Close(); 
       } 
      } 
      protocols.Close(); 
     } 
     return rebootRequired; 
    } 

    private static bool EnsureValue(RegistryKey key, string name, bool value) 
    { 
     object currentValue = key.GetValue(name); 
     object expectedValue = value ? 1 : 0; 
     if (currentValue == null || !object.Equals(currentValue, expectedValue)) 
     { 
      key.SetValue(name, expectedValue); 
      return true; 
     } 
     return false; 
    } 
Смежные вопросы