Skip to content

Commit

Permalink
code fence entire element (dotnet#42303)
Browse files Browse the repository at this point in the history
  • Loading branch information
gewarren authored Aug 23, 2024
1 parent ec12733 commit 28bd717
Show file tree
Hide file tree
Showing 41 changed files with 2,174 additions and 2,174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The viewer automatically follows the configuration merge path and creates a view
### Services

The **Services** node displays all of the services currently assigned in the configuration file. Each sub-node in the tree corresponds to a sub-element of the <`services`> element in the configuration file.
The **Services** node displays all of the services currently assigned in the configuration file. Each sub-node in the tree corresponds to a sub-element of the `<services>` element in the configuration file.

When you click the **Services** node, you can view or perform tasks on the service Summary Page in the **Detail** Pane.

Expand Down Expand Up @@ -116,7 +116,7 @@ You can create a new service endpoint configuration in the following ways:
### Client

The **Client** node displays all of the client endpoints in the configuration file. Every sub-node in the tree corresponds to a sub-element of the <`client`> element in the configuration file.
The **Client** node displays all of the client endpoints in the configuration file. Every sub-node in the tree corresponds to a sub-element of the `<client>` element in the configuration file.

When you click the **Client** node, you can view or perform tasks on the client **Summary Page** in the **Detail Pane**.

Expand Down Expand Up @@ -176,7 +176,7 @@ If the standard endpoint is in used, a warning message is displayed when you att

Binding configurations are used to configure bindings on endpoints. Such configuration settings are stored in the **Binding** node. Endpoints reference binding configurations by name and multiple endpoints can reference a single binding configuration.

The **Bindings** node displays all of the binding settings in the configuration file. Every sub-node in the tree corresponds to a sub-element in the <`bindings`> element in the configuration file.
The **Bindings** node displays all of the binding settings in the configuration file. Every sub-node in the tree corresponds to a sub-element in the `<bindings>` element in the configuration file.

When you click the **Bindings** node, you can view or perform tasks on the binding **Summary Page** in the **Detail Pane**.

Expand Down Expand Up @@ -220,7 +220,7 @@ A custom binding is a collection of binding elements that form a stack. Each bin

### Diagnostics

The **Diagnostics** node displays all of the diagnostic settings in the configuration file. It enables you to turn performance counters on or off, enable or disable Windows Management Instrumentation (WMI), configure WCF tracing, and configure WCF message logging. The settings in the **Diagnostics** node correspond to the <`system.diagnostics`> section, and `<diagnostics>` section in `<system.serviceModel>` in the configuration file.
The **Diagnostics** node displays all of the diagnostic settings in the configuration file. It enables you to turn performance counters on or off, enable or disable Windows Management Instrumentation (WMI), configure WCF tracing, and configure WCF message logging. The settings in the **Diagnostics** node correspond to the `<system.diagnostics>` section, and `<diagnostics>` section in `<system.serviceModel>` in the configuration file.

When you click the **Diagnostics** node, you can view or perform tasks on the diagnostics **Summary Page** in the **Detail Pane**.

Expand Down Expand Up @@ -384,7 +384,7 @@ One way to create a new configuration file is to use the New Service Element Wiz
## Configuring COM+

The Service Configuration Editor enables you to create a new configuration file for an existing COM+ application, or edit an existing COM+ configuration. The **COM Contract** node is only visible when the <`comContract`> section exists in the configuration file.
The Service Configuration Editor enables you to create a new configuration file for an existing COM+ application, or edit an existing COM+ configuration. The **COM Contract** node is only visible when the `<comContract>` section exists in the configuration file.

### Creating a New COM+ Configuration

Expand Down
500 changes: 250 additions & 250 deletions docs/framework/wcf/configuring-services-using-configuration-files.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/framework/wcf/configuring-wcf-services-in-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class Service1 : IService1
}
```

The settings in the <`protocolMappings`> section are only used if no application endpoints are added to the <xref:System.ServiceModel.ServiceConfiguration> programmatically.You can optionally load the service configuration from the default application configuration file by calling <xref:System.ServiceModel.ServiceConfiguration.LoadFromConfiguration%2A> and then change the settings. The <xref:System.ServiceModel.ServiceConfiguration.LoadFromConfiguration> class also allows you to load configuration from a centralized configuration. The following code illustrates how to implement this:
The settings in the `<protocolMappings>` section are only used if no application endpoints are added to the <xref:System.ServiceModel.ServiceConfiguration> programmatically.You can optionally load the service configuration from the default application configuration file by calling <xref:System.ServiceModel.ServiceConfiguration.LoadFromConfiguration%2A> and then change the settings. The <xref:System.ServiceModel.ServiceConfiguration.LoadFromConfiguration> class also allows you to load configuration from a centralized configuration. The following code illustrates how to implement this:

```csharp
public class Service1 : IService1
Expand All @@ -88,7 +88,7 @@ public class Service1 : IService1
```

> [!IMPORTANT]
> Note that <xref:System.ServiceModel.ServiceConfiguration.LoadFromConfiguration%2A> ignores <`host`> settings within the <`service`> tag of <`system.serviceModel`>. Conceptually, <`host`> is about host configuration, not service configuration, and it gets loaded before the Configure method executes.
> Note that <xref:System.ServiceModel.ServiceConfiguration.LoadFromConfiguration%2A> ignores `<host>` settings within the `<service>` tag of `<system.serviceModel>`. Conceptually, `<host>` is about host configuration, not service configuration, and it gets loaded before the Configure method executes.
## See also

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Typically, you do not have to set the identity on a service because the selectio

If you change the client credential type in the binding previously shown to `Certificate`, then the generated WSDL contains a Base64 serialized X.509 certificate for the identity value as shown in the following code. This is the default for all client credential types other than Windows.

You can change the value of the default service identity or change the type of the identity by using the <`identity`> element in configuration or by setting the identity in code. The following configuration code sets a domain name system (DNS) identity with the value `contoso.com`.
You can change the value of the default service identity or change the type of the identity by using the `<identity>` element in configuration or by setting the identity in code. The following configuration code sets a domain name system (DNS) identity with the value `contoso.com`.

### Set Identity Programmatically

Expand Down
232 changes: 116 additions & 116 deletions docs/framework/wcf/extending/specifying-a-custom-crypto-algorithm.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,124 +6,124 @@ ms.topic: how-to
---
# Specifying a Custom Crypto Algorithm

WCF allows you to specify a custom crypto algorithm to use when encrypting data or computing digital signatures. This is done by the following steps:
1. Derive a class from <xref:System.ServiceModel.Security.SecurityAlgorithmSuite>
2. Register the algorithm
3. Configure the binding with the <xref:System.ServiceModel.Security.SecurityAlgorithmSuite>-derived class.
## Derive a class from SecurityAlgorithmSuite

The <xref:System.ServiceModel.Security.SecurityAlgorithmSuite> is an abstract base class that allows you to specify the algorithm to use when performing various security related operations. For example, computing a hash for a digital signature or encrypting a message. The following code shows how to derive a class from <xref:System.ServiceModel.Security.SecurityAlgorithmSuite>:
```csharp
public class MyCustomAlgorithmSuite : SecurityAlgorithmSuite
{
public override string DefaultAsymmetricKeyWrapAlgorithm
{
get { return SecurityAlgorithms.RsaOaepKeyWrap; }
}
public override string DefaultAsymmetricSignatureAlgorithm
{
get { return SecurityAlgorithms.RsaSha1Signature; }
}
public override string DefaultCanonicalizationAlgorithm
{
get { return SecurityAlgorithms.ExclusiveC14n; ; }
}
public override string DefaultDigestAlgorithm
{
get { return SecurityAlgorithms.MyCustomHashAlgorithm; }
}
public override string DefaultEncryptionAlgorithm
{
get { return SecurityAlgorithms.Aes128Encryption; }
}
public override int DefaultEncryptionKeyDerivationLength
{
get { return 128; }
}
public override int DefaultSignatureKeyDerivationLength
{
get { return 128; }
}
public override int DefaultSymmetricKeyLength
{
get { return 128; }
}
public override string DefaultSymmetricKeyWrapAlgorithm
{
get { return SecurityAlgorithms.Aes128Encryption; }
}
public override string DefaultSymmetricSignatureAlgorithm
{
get { return SecurityAlgorithms.HmacSha1Signature; }
}
public override bool IsAsymmetricKeyLengthSupported(int length)
{
return length >= 1024 && length <= 4096;
}
public override bool IsSymmetricKeyLengthSupported(int length)
{
return length >= 128 && length <= 256;
}
}
```
## Register the Custom Algorithm

Registration can be done in a configuration file or in imperative code. Registering a custom algorithm is done by creating a mapping between a class that implements a crypto service provider and an alias. The alias is then mapped to a URI which is used when specifying the algorithm in the WCF service's binding. The following configuration snippet illustrates how to register a custom algorithm in config:
```xml
<configuration>
<mscorlib>
<cryptographySettings>
<cryptoNameMapping>
<cryptoClasses>
<cryptoClass SHA256CSP="System.Security.Cryptography.SHA256CryptoServiceProvider, System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</cryptoClasses>
<nameEntry name="http://contoso.com/CustomAlgorithms/CustomHashAlgorithm"
class="SHA256CSP" />
</cryptoNameMapping>
</cryptographySettings>
</mscorlib>
</configuration>
```
The section under the <`cryptoClasses`> element creates the mapping between the SHA256CryptoServiceProvider and the alias "SHA256CSP". The <`nameEntry`> element creates the mapping between the "SHA256CSP" alias and the specified URL `http://contoso.com/CustomAlgorithms/CustomHashAlgorithm`.
To register the custom algorithm in code use the <xref:System.Security.Cryptography.CryptoConfig.AddAlgorithm(System.Type,System.String[])> method. This method creates both mappings. The following example shows how to call this method:
WCF allows you to specify a custom crypto algorithm to use when encrypting data or computing digital signatures. This is done by the following steps:

1. Derive a class from <xref:System.ServiceModel.Security.SecurityAlgorithmSuite>

2. Register the algorithm

3. Configure the binding with the <xref:System.ServiceModel.Security.SecurityAlgorithmSuite>-derived class.

## Derive a class from SecurityAlgorithmSuite

The <xref:System.ServiceModel.Security.SecurityAlgorithmSuite> is an abstract base class that allows you to specify the algorithm to use when performing various security related operations. For example, computing a hash for a digital signature or encrypting a message. The following code shows how to derive a class from <xref:System.ServiceModel.Security.SecurityAlgorithmSuite>:

```csharp
public class MyCustomAlgorithmSuite : SecurityAlgorithmSuite
{
public override string DefaultAsymmetricKeyWrapAlgorithm
{
get { return SecurityAlgorithms.RsaOaepKeyWrap; }
}

public override string DefaultAsymmetricSignatureAlgorithm
{
get { return SecurityAlgorithms.RsaSha1Signature; }
}

public override string DefaultCanonicalizationAlgorithm
{
get { return SecurityAlgorithms.ExclusiveC14n; ; }
}

public override string DefaultDigestAlgorithm
{
get { return SecurityAlgorithms.MyCustomHashAlgorithm; }
}

public override string DefaultEncryptionAlgorithm
{
get { return SecurityAlgorithms.Aes128Encryption; }
}

public override int DefaultEncryptionKeyDerivationLength
{
get { return 128; }
}

public override int DefaultSignatureKeyDerivationLength
{
get { return 128; }
}

public override int DefaultSymmetricKeyLength
{
get { return 128; }
}

public override string DefaultSymmetricKeyWrapAlgorithm
{
get { return SecurityAlgorithms.Aes128Encryption; }
}

public override string DefaultSymmetricSignatureAlgorithm
{
get { return SecurityAlgorithms.HmacSha1Signature; }
}

public override bool IsAsymmetricKeyLengthSupported(int length)
{
return length >= 1024 && length <= 4096;
}

public override bool IsSymmetricKeyLengthSupported(int length)
{
return length >= 128 && length <= 256;
}
}
```

## Register the Custom Algorithm

Registration can be done in a configuration file or in imperative code. Registering a custom algorithm is done by creating a mapping between a class that implements a crypto service provider and an alias. The alias is then mapped to a URI which is used when specifying the algorithm in the WCF service's binding. The following configuration snippet illustrates how to register a custom algorithm in config:

```xml
<configuration>
<mscorlib>
<cryptographySettings>
<cryptoNameMapping>
<cryptoClasses>
<cryptoClass SHA256CSP="System.Security.Cryptography.SHA256CryptoServiceProvider, System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</cryptoClasses>
<nameEntry name="http://contoso.com/CustomAlgorithms/CustomHashAlgorithm"
class="SHA256CSP" />
</cryptoNameMapping>
</cryptographySettings>
</mscorlib>
</configuration>
```

The section under the `<cryptoClasses>` element creates the mapping between the SHA256CryptoServiceProvider and the alias "SHA256CSP". The `<nameEntry>` element creates the mapping between the "SHA256CSP" alias and the specified URL `http://contoso.com/CustomAlgorithms/CustomHashAlgorithm`.

To register the custom algorithm in code use the <xref:System.Security.Cryptography.CryptoConfig.AddAlgorithm(System.Type,System.String[])> method. This method creates both mappings. The following example shows how to call this method:

```csharp
// Register the custom URI string defined for the hashAlgorithm in MyCustomAlgorithmSuite class to create the
// SHA256CryptoServiceProvider hash algorithm object.
CryptoConfig.AddAlgorithm(typeof(SHA256CryptoServiceProvider), "http://contoso.com/CustomAlgorithms/CustomHashAlgorithm");
```
## Configure the Binding

You configure the binding by specifying the custom <xref:System.ServiceModel.Security.SecurityAlgorithmSuite>-derived class in the binding settings as shown in the following code snippet:
```csharp
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Message.AlgorithmSuite = new MyCustomAlgorithmSuite();
```
For a complete code example, see the [Cryptographic Agility in WCF Security](../samples/cryptographic-agility-in-wcf-security.md) sample.
// SHA256CryptoServiceProvider hash algorithm object.
CryptoConfig.AddAlgorithm(typeof(SHA256CryptoServiceProvider), "http://contoso.com/CustomAlgorithms/CustomHashAlgorithm");
```

## Configure the Binding

You configure the binding by specifying the custom <xref:System.ServiceModel.Security.SecurityAlgorithmSuite>-derived class in the binding settings as shown in the following code snippet:

```csharp
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Message.AlgorithmSuite = new MyCustomAlgorithmSuite();
```

For a complete code example, see the [Cryptographic Agility in WCF Security](../samples/cryptographic-agility-in-wcf-security.md) sample.

## See also

- [Securing Services and Clients](../feature-details/securing-services-and-clients.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ Once you have the configuration handler class, it can be integrated into the WCF

#### To register and use a custom client credentials configuration handler in the application configuration

1. Add an <`extensions`> element and a <`behaviorExtensions`> element to the configuration file.
1. Add an `<extensions>` element and a `<behaviorExtensions>` element to the configuration file.

2. Add an <`add`> element to the <`behaviorExtensions`> element and set the `name` attribute to an appropriate value.
2. Add an `<add>` element to the `<behaviorExtensions>` element and set the `name` attribute to an appropriate value.

3. Set the `type` attribute to the fully-qualified type name. Also include the assembly name and other assembly attributes.

Expand All @@ -124,7 +124,7 @@ Once you have the configuration handler class, it can be integrated into the WCF
</system.serviceModel>
```

4. After registering your configuration handler, the custom credentials element can be used inside the same configuration file instead of the system-provided <`clientCredentials`> element. You can use both the system-provided properties and any new properties that you have added to your configuration handler implementation. The following example sets the value of a custom property using the `creditCardNumber` attribute.
4. After registering your configuration handler, the custom credentials element can be used inside the same configuration file instead of the system-provided `<clientCredentials>` element. You can use both the system-provided properties and any new properties that you have added to your configuration handler implementation. The following example sets the value of a custom property using the `creditCardNumber` attribute.

```xml
<behaviors>
Expand Down
Loading

0 comments on commit 28bd717

Please sign in to comment.