/// <summary> /// Updates the endpoint configuration. /// </summary> public void Update(EndpointConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } m_configuration = (EndpointConfiguration)configuration.MemberwiseClone(); BinaryEncodingSupport binaryEncodingSupport = m_description.EncodingSupport; // check if the configuration restricts the encoding if the endpoint supports both. if (binaryEncodingSupport == BinaryEncodingSupport.Optional) { binaryEncodingSupport = m_binaryEncodingSupport; } if (binaryEncodingSupport == BinaryEncodingSupport.None) { m_configuration.UseBinaryEncoding = false; } if (binaryEncodingSupport == BinaryEncodingSupport.Required) { m_configuration.UseBinaryEncoding = true; } }
/// <summary> /// Called when a secure channel is created by the client. /// </summary> /// <param name="implementationInfo">Information about the secure channel implementation.</param> /// <param name="endpointUrl">The identifier assigned to the secure channel</param> /// <param name="secureChannelId">The identifier assigned to the secure channel</param> /// <param name="endpoint">The endpoint.</param> /// <param name="clientCertificate">The client certificate.</param> /// <param name="serverCertificate">The server certificate.</param> /// <param name="encodingSupport">The type of encoding supported by the channel.</param> public static void SecureChannelCreated( string implementationInfo, string endpointUrl, string secureChannelId, EndpointDescription endpoint, X509Certificate2 clientCertificate, X509Certificate2 serverCertificate, BinaryEncodingSupport encodingSupport) { // do nothing if security turned off. if ((Utils.TraceMask & Utils.TraceMasks.Security) == 0) { return; } if (endpoint != null) { string encoding; if (encodingSupport == BinaryEncodingSupport.Required) { encoding = "Binary"; } else if (encodingSupport == BinaryEncodingSupport.None) { encoding = "Xml"; } else { encoding = "BinaryOrXml"; } Utils.LogInfo("SECURE CHANNEL CREATED [{0}] [ID={1}] Connected To: {2} [{3}/{4}/{5}]", implementationInfo, secureChannelId, endpointUrl, endpoint.SecurityMode.ToString(), SecurityPolicies.GetDisplayName(endpoint.SecurityPolicyUri), encoding); if (endpoint.SecurityMode != MessageSecurityMode.None) { Utils.LogCertificate("Client Certificate: ", clientCertificate); Utils.LogCertificate("Server Certificate: ", serverCertificate); } } else { Utils.LogInfo("SECURE CHANNEL CREATED [{0}] [ID={1}] Connected To: {2}", implementationInfo, secureChannelId, endpointUrl); } }
/// <summary> /// Called when a secure channel is created by the client. /// </summary> /// <param name="implementationInfo">Information about the secure channel implementation.</param> /// <param name="endpointUrl">The identifier assigned to the secure channel</param> /// <param name="secureChannelId">The identifier assigned to the secure channel</param> /// <param name="endpoint">The endpoint.</param> /// <param name="clientCertificate">The client certificate.</param> /// <param name="serverCertificate">The server certificate.</param> /// <param name="encodingSupport">The type of encoding supported by the channel.</param> public static void SecureChannelCreated( string implementationInfo, string endpointUrl, string secureChannelId, EndpointDescription endpoint, X509Certificate2 clientCertificate, X509Certificate2 serverCertificate, BinaryEncodingSupport encodingSupport) { // do nothing if security turned off. if ((Utils.TraceMask & Utils.TraceMasks.Security) == 0) { return; } StringBuilder buffer = new StringBuilder(); buffer.Append("SECURE CHANNEL CREATED"); buffer.Append(" ["); buffer.Append(implementationInfo); buffer.Append("]"); buffer.Append(" [ID="); buffer.Append(secureChannelId); buffer.Append("]"); buffer.Append(" Connected To: "); buffer.Append(endpointUrl); if (endpoint != null) { buffer.Append(" ["); buffer.AppendFormat(CultureInfo.InvariantCulture, "{0}", endpoint.SecurityMode); buffer.Append("/"); buffer.Append(SecurityPolicies.GetDisplayName(endpoint.SecurityPolicyUri)); buffer.Append("/"); if (encodingSupport == BinaryEncodingSupport.Required) { buffer.Append("Binary"); } else if (encodingSupport == BinaryEncodingSupport.None) { buffer.Append("Xml"); } else { buffer.Append("BinaryOrXml"); } buffer.Append("]"); if (endpoint.SecurityMode != MessageSecurityMode.None) { if (clientCertificate != null) { buffer.Append(" Client Certificate: ["); buffer.Append(clientCertificate.Subject); buffer.Append("] ["); buffer.Append(clientCertificate.Thumbprint); buffer.Append("]"); } if (serverCertificate != null) { buffer.Append(" Server Certificate: ["); buffer.Append(serverCertificate.Subject); buffer.Append("] ["); buffer.Append(serverCertificate.Thumbprint); buffer.Append("]"); } } } Utils.Trace(Utils.TraceMasks.Security, buffer.ToString()); }