forked from IdentityStream/HttpMessageSigning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Snippets.cs
42 lines (31 loc) · 1.49 KB
/
Snippets.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Net.Http;
using System.Security.Cryptography;
using System.ServiceModel;
using IdentityStream.HttpMessageSigning.ServiceModel;
namespace IdentityStream.HttpMessageSigning.Tests {
public class Snippets {
// Fake endpoint for snippet purposes
public class TheEndpointClient : ClientBase<string> {
public TheEndpointClient(BasicHttpsBinding binding, EndpointAddress remoteAddress) {
}
}
public void WCF_Client_Setup(BasicHttpsBinding binding, EndpointAddress endpointAddress, RSA rsaOrECDsaAlgorithm) {
#region WCF_Endpoint_UseHttpMessageSigning
var signatureAlgorithm = SignatureAlgorithm.Create(rsaOrECDsaAlgorithm);
var config = new HttpMessageSigningConfiguration("key-id", signatureAlgorithm);
using var client = new TheEndpointClient(binding, endpointAddress);
client.UseHttpMessageSigning(config);
// Make calls using client :)
#endregion
}
public void HttpClient_Setup(RSA rsaOrECDsaAlgorithm) {
#region HttpClient_SigningHttpMessageHandler
var signatureAlgorithm = SignatureAlgorithm.Create(rsaOrECDsaAlgorithm);
var config = new HttpMessageSigningConfiguration("key-id", signatureAlgorithm);
var handler = new SigningHttpMessageHandler(config);
using var client = new HttpClient(handler);
// Make requests using client :)
#endregion
}
}
}