Skip to content

Commit

Permalink
FIX-2352 Add HTTP documentation (#2375)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasbruvik authored Apr 24, 2024
1 parent ca3fc12 commit 429d279
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Docs/enable_http.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Enable HTTP WITSML servers

> :warning: **Using HTTP to connect to WITSML servers is not secure.** HTTP does not encrypt data, making it vulnerable to interception, tampering, and man-in-the-middle attacks. It is strongly recommended to use HTTPS, which encrypts communications, to protect against these risks.
## Implementation Details
If enabling HTTP between the API and your WITSML server is required, here is how to modify the service binding in the API to accommodate HTTP communication. The changes should be applied to `WitsmlClientBase.cs` in the API. With these changes, only the servers with a http-scheme will use http. If your server URL begins with https, it will still use secure communication.

```c#
// Modify the serviceBinding in the constructor.
Binding serviceBinding = CreateBinding(options);


// Add these two methods
private static Binding CreateBinding(WitsmlClientOptions options)
{
Uri uri = new(options.Hostname);

if (uri.Scheme == "http")
{
return CreateBasicHttpBinding(options.RequestTimeOut);
}
else if (uri.Scheme == "https" && options.ClientCertificate == null)
{
return CreateBasicBinding(options.RequestTimeOut);
}
else if (uri.Scheme == "https" && options.ClientCertificate != null)
{
return CreateCertificateAndBasicBinding();
}
throw new NotSupportedException($"No binding supported for the client options '{options}'.");
}

private static BasicHttpBinding CreateBasicHttpBinding(TimeSpan requestTimeout)
{
return new BasicHttpBinding
{
Security =
{
Mode = BasicHttpSecurityMode.TransportCredentialOnly,
Transport =
{
ClientCredentialType = HttpClientCredentialType.Basic
}
},
MaxReceivedMessageSize = int.MaxValue,
SendTimeout = requestTimeout
};
}
```
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Please see our [server readme](./Docker/Server/README.md).
## API custom client access
Please visit [API client access](/Docs/APICLIENT.md).

## Enable HTTP WITSML servers
Please see [enable HTTP](/Docs/enable_http.md).

## Community
Please read and respect the [CODE OF CONDUCT](/CODE_OF_CONDUCT.md)

Expand Down

0 comments on commit 429d279

Please sign in to comment.