我正在尝试使用EWS获取忙/闲 我已经安装了最新的nuget包Microsoft.Exchange.WebServices
我也设置了我所知道的忽略证书的一切。错误:
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
我用来获取约会的代码:
//Set up the service with correct credentials.
var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1)
{
Credentials = new WebCredentials(Account, Password, Domain),
TraceEnabled = true,
EnableScpLookup = false
};
service.Url = new Uri(ServiceUrl);
// Create a list of attendees.
var attendees = Contacts.Select(contact => new AttendeeInfo { SmtpAddress = contact.Email, AttendeeType = MeetingAttendeeType.Required }).ToList();
// Specify availability options.
var myOptions = new AvailabilityOptions
{
MeetingDuration = 30,
RequestedFreeBusyView = FreeBusyViewType.DetailedMerged,
DetailedSuggestionsWindow = new TimeWindow(DateTime.Now, DateTime.Now.AddDays(Days))
};
// Return a set of free/busy times.
var freeBusyResults = service.GetUserAvailability(attendees, new TimeWindow(DateTime.Now, DateTime.Now.AddDays(Days)),AvailabilityData.FreeBusyAndSuggestions, myOptions);
此代码适用于我拥有的6台交换服务器中的5台,但其中一台提供“请求失败。请求已中止:无法创建SSL / TLS安全通道。”错误信息。
如果我设置fiddler作为呼叫的代理,并告诉fiddler解密,一切正常。
我只想忽略所有ssl错误并获取数据,我该怎么做?
答案 0 :(得分:0)
Managed API只是使用HTTPWebRequest作为执行请求/响应的基础类。如果它与小提琴手一起工作,那么你的问题很可能与环境/客户有关。我建议您启用跟踪https://blogs.msdn.microsoft.com/dgorti/2005/09/18/using-system-net-tracing/,然后您应该能够看到失败时在较低级别发生的情况。