【问题标题】:Are Exchange Online (EWS) WebCredentials passed securely?Exchange Online (EWS) WebCredentials 是否安全传递?
【发布时间】:2014-01-25 19:03:57
【问题描述】:

我正在编写一个简单的 .NET Web 应用程序来使用 EWS 在我们的 Exchange Online (Office 365) 云站点上查看一些房间日历。我知道如何在我的代码中创建 Exchange 服务,将凭据设置为新的 WebCredentials(使用有效的用户名/密码),并自动发现服务 URL。

我的问题是:用户名/密码对是安全发送还是明文发送?

如果这不安全,我是否将服务的 URL 显式设置为 https://outlook.office365.com/EWS/Exchange.asmx URI?

【问题讨论】:

  • 如何连接到 EWS?请向我们展示您的代码。
  • ExchangeService svc = new ExchangeService(); svc.Credentials = new WebCredentials(AuthEmailAddress, AuthEmailPassword); svc.AutodiscoverUrl(AutoDiscoverEmailAddress);

标签: c# security exchange-server credentials


【解决方案1】:

您可以调用set the url directly using exchangeService.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");,而不是调用AutoDiscoverUrl()

此外,在调用 AutoDiscoverUrl() 之后,您还可以检查 ExchangeService 对象的 Url 属性,以查看它是否解析为安全端点或您信任的端点(来自配置文件中的特定列表例如)。

为了绝对确保返回的 Url 安全可靠,您应该验证返回的证书是否来自您期望的组织,并且该证书是由受信任的机构签署的。这个process is explained here。他文章中提到的默认实现也接受自签名证书,您可能不想在生产代码中这样做。例如,您可以将证书固定到特定的指纹。

如果要排除自签名证书,请更改引用示例中的以下代码以返回 false:

// When processing reaches this line, the only errors in the certificate chain are 
// untrusted root errors for self-signed certificates. These certificates are valid
// for default Exchange server installations, so return true.

// Or when you know that the certificate is signed by a trusted root authority, return false.
return false;

为了回答您的问题,用户名/密码通常使用 NTLM 或 Kerberos 安全发送。在最坏的情况下they can be sent using basic authentication,但是如果您通过 SSL 连接,那么只要您正确验证 SSL 证书,就不容易拦截密码。

【讨论】:

  • 我已经明确设置了网址,但是您的评论很好(谢谢)。我现在无法访问我的代码,但明天我会检查 URL 属性。这可能已经足够好了。明天我也会沿着证书路线走。再次感谢。
  • 谢谢。你拯救了这一天。
猜你喜欢
  • 2020-10-08
  • 1970-01-01
  • 2021-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-21
相关资源
最近更新 更多