private void GetRpsCertificateThumbprint() { if (this.isCasServer) { Exception ex = null; try { ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 614, "GetRpsCertificateThumbprint", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Monitoring\\Tasks\\TestRemotePowerShellConnectivity.cs"); ServiceEndpoint endpoint = topologyConfigurationSession.GetEndpointContainer().GetEndpoint("ForwardSyncRpsEndPoint"); this.certThumbprint = TlsCertificateInfo.FindFirstCertWithSubjectDistinguishedName(endpoint.CertificateSubject).Thumbprint; } catch (ServiceEndpointNotFoundException ex2) { ex = ex2; } catch (ArgumentException ex3) { ex = ex3; } if (ex != null) { this.monitoringData.Events.Add(new MonitoringEvent("MSExchange Monitoring PowerShellConnectivity External", 1012, EventTypeEnumeration.Warning, "PS ExternalUrl test for certificate connection skipped:" + ex.ToString())); } } }
private DNSWebSvcClient OpenDnsServiceClient() { DNSWebSvcClient dnswebSvcClient = new DNSWebSvcClient(this.wsb, new EndpointAddress(this.endpointUrl, new AddressHeader[0])); dnswebSvcClient.ClientCredentials.ClientCertificate.Certificate = TlsCertificateInfo.FindFirstCertWithSubjectDistinguishedName(this.authorizationCertificateSubject); dnswebSvcClient.Open(); return(dnswebSvcClient); }
// Token: 0x06000CA0 RID: 3232 RVA: 0x00038B1C File Offset: 0x00036D1C internal ServiceProxyPool(WSHttpBinding binding, ServiceEndpoint serviceEndpoint) { this.pool = new ConcurrentQueue <T>(); this.channelFactory = new ChannelFactory <T>(binding, serviceEndpoint.Uri.ToString()); try { this.channelFactory.Credentials.ClientCertificate.Certificate = TlsCertificateInfo.FindFirstCertWithSubjectDistinguishedName(serviceEndpoint.CertificateSubject); } catch (ArgumentException ex) { throw new GlsPermanentException(DirectoryStrings.PermanentGlsError(ex.Message)); } ServicePointManager.DefaultConnectionLimit = Math.Max(ServicePointManager.DefaultConnectionLimit, 8 * Environment.ProcessorCount); }
protected override DirectorySyncClient CreateService() { ServiceEndpoint serviceEndpoint = null; try { serviceEndpoint = MsoSyncService.GetMsoEndpoint(); } catch (Exception innerException) { throw new CouldNotCreateMsoSyncServiceException(Strings.CouldNotGetMsoEndpoint, innerException); } DirectorySyncClient result; try { EndpointAddress remoteAddress = new EndpointAddress(serviceEndpoint.Uri, new AddressHeader[0]); result = new DirectorySyncClient(new WSHttpBinding(SecurityMode.Transport) { Security = { Transport = { ClientCredentialType = HttpClientCredentialType.Certificate } }, MaxBufferPoolSize = 5242880L, MaxReceivedMessageSize = 5242880L }, remoteAddress) { ClientCredentials = { ClientCertificate = { Certificate = TlsCertificateInfo.FindFirstCertWithSubjectDistinguishedName(serviceEndpoint.CertificateSubject) } } }; } catch (Exception ex) { throw new CouldNotCreateMsoSyncServiceException(ex.Message, ex); } return(result); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); WebSvcDns webSvcDns = new WebSvcDns(null, ""); DNSWebSvcClient dnswebSvcClient = null; AcceptedDomain dataObject = this.DataObject; string domain = dataObject.DomainName.Domain; try { dnswebSvcClient = new DNSWebSvcClient(webSvcDns.Wsb, new EndpointAddress(this.dnsEndpoint, new AddressHeader[0])); dnswebSvcClient.ClientCredentials.ClientCertificate.Certificate = TlsCertificateInfo.FindFirstCertWithSubjectDistinguishedName(this.certificateSubject); dnswebSvcClient.Open(); if (dnswebSvcClient.IsDomainAvailable(domain)) { return; } ResourceRecord[] allResourceRecordsByDomainName = dnswebSvcClient.GetAllResourceRecordsByDomainName(domain); foreach (ResourceRecord record in allResourceRecordsByDomainName) { base.WriteObject(new WebDnsRecord(record)); } } catch (TimeoutException exception) { base.WriteError(exception, ErrorCategory.InvalidArgument, dataObject); } catch (SecurityAccessDeniedException exception2) { base.WriteError(exception2, ErrorCategory.InvalidArgument, dataObject); } catch (CommunicationException exception3) { base.WriteError(exception3, ErrorCategory.InvalidArgument, dataObject); } finally { if (dnswebSvcClient != null) { dnswebSvcClient.Close(); } } TaskLogger.LogExit(); }
// Token: 0x06000B45 RID: 2885 RVA: 0x00033B28 File Offset: 0x00031D28 private static ChannelFactory <TClient> CreateChannelFactory(string endpointName, ServiceEndpoint serviceEndpoint, Binding defaultBinding, Trace tracer) { ArgumentValidator.ThrowIfNull("endpointName", endpointName); ArgumentValidator.ThrowIfNull("serviceEndpoint", serviceEndpoint); ArgumentValidator.ThrowIfNull("defaultBinding", defaultBinding); ArgumentValidator.ThrowIfNull("tracer", tracer); ChannelFactory <TClient> channelFactory = null; try { channelFactory = WcfUtils.TryCreateChannelFactoryFromConfig <TClient>(endpointName); } catch (Exception ex) { tracer.TraceError <string, string>(0L, "ServiceProxyPool - Error Creating channel factory from config file for {0}. Details {1}", endpointName, ex.ToString()); Globals.LogEvent(DirectoryEventLogConstants.Tuple_WcfClientConfigError, endpointName, new object[] { endpointName, ex.Message }); } if (channelFactory == null) { channelFactory = new ChannelFactory <TClient>(defaultBinding, serviceEndpoint.Uri.ToString()); } WSHttpBinding wshttpBinding = defaultBinding as WSHttpBinding; if (wshttpBinding != null && wshttpBinding.Security.Transport.ClientCredentialType == HttpClientCredentialType.Certificate) { try { channelFactory.Credentials.ClientCertificate.Certificate = TlsCertificateInfo.FindFirstCertWithSubjectDistinguishedName(serviceEndpoint.CertificateSubject); } catch (ArgumentException ex2) { throw new GlsPermanentException(DirectoryStrings.PermanentGlsError(ex2.Message)); } } DirectoryServiceProxyPool <TClient> .ConfigWCFServicePointManager(); return(channelFactory); }
public static IMailboxReplicationProxyService CreateChannel(MailboxReplicationProxyClient proxyClient) { ChannelFactory <IMailboxReplicationProxyService> channelFactory = proxyClient.ChannelFactory; EndpointAddress address = proxyClient.Endpoint.Address; if (address.Uri != null && (address.Uri.Scheme == Uri.UriSchemeHttps || address.Uri.Scheme == Uri.UriSchemeHttp)) { if (!ExchangeSessionAwareClientsHelper.webRequestCreator.IsDisabled) { UriBuilder uriBuilder = new UriBuilder(address.Uri); uriBuilder.Path = proxyClient.RequestContext.Id.ToString(); if (proxyClient.UseCertificateToAuthenticate) { string config = ConfigBase <MRSConfigSchema> .GetConfig <string>("ProxyClientCertificateSubject"); try { channelFactory.Credentials.ClientCertificate.Certificate = TlsCertificateInfo.FindFirstCertWithSubjectDistinguishedName(config, false); } catch (ArgumentException ex) { throw new CertificateLoadErrorException(config, ex.Message, ex); } } return(channelFactory.CreateChannel(address, uriBuilder.Uri)); } CustomBinding customBinding = channelFactory.Endpoint.Binding as CustomBinding; if (customBinding != null) { HttpsTransportBindingElement httpsTransportBindingElement = customBinding.Elements.Find <HttpsTransportBindingElement>(); if (httpsTransportBindingElement != null) { httpsTransportBindingElement.AllowCookies = true; } } } return(channelFactory.CreateChannel(address)); }