2014-01-07 28 views
3

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

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

如果这不安全,如果我明确地将服务的URL设置为https://outlook.office365.com/EWS/Exchange.asmx URI,那么该怎么办?

+0

**您如何连接到EWS?请告诉我们你的代码。 – Dai

+0

'ExchangeService svc = new ExchangeService(); svc.Credentials =新的WebCredentials(AuthEmailAddress,AuthEmailPassword); svc.AutodiscoverUrl(AutoDiscoverEmailAddress);' – TheDudeDude

回答

3

不要致电AutoDiscoverUrl(),您可以set the url directly usingexchangeService.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");

此外,调用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证书,就不应该很容易拦截密码。

+0

我已经明确地设置了URL,但是您的评论很好(谢谢)。我现在无法访问我的代码,但明天我会检查URL属性。这可能够好。我明天也会走下证书路线。再次感谢。 – TheDudeDude

相关问题