This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void KillExistingHosts(int port) | |
{ | |
if (Environment.OSVersion.Platform != PlatformID.Win32NT) | |
{ | |
return; | |
} | |
using (var existing = Win32.FindProcessOwner(port)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FakeRealmService : IRealmService | |
{ | |
public FakeRealmService(string realm) | |
{ | |
Name = realm; | |
} | |
public IRealmSettings Settings => new FakeRealmSettings(); | |
public IPrincipalService Principals => new FakePrincipalService(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static async Task Main() | |
{ | |
var builder = new HostBuilder() | |
.ConfigureLogging((_, factory) => | |
{ | |
factory.AddConsole(opt => opt.IncludeScopes = true); | |
factory.AddFilter<ConsoleLoggerProvider>(level => level >= LogLevel.Trace); | |
}); | |
var host = builder.Build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyStartup : IStartupTransform | |
{ | |
public void Transform(IServiceCollection services) | |
{ | |
services.AddScoped<IKeyStorageService, MyStorageService>(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IKeyStorageService | |
{ | |
Task<IKeyIdentifier> AddKey(IEnclaveKey key); | |
Task<IEnclaveKey> GetKey(IKeyIdentifier id); | |
Task<IQueryable<IKeyIdentifier>> ListKeys(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ICryptoProcessor | |
{ | |
Task<IEnclaveKey> GenerateKey(string keyType); | |
Task<string> Encrypt(IEnclaveKey key, object value); | |
Task<T> Decrypt<T>(IEnclaveKey key, string ciphertext); | |
Task<string> Sign(IEnclaveKey key, object value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"StartupTransformType": "My.Namespace.MyClass, MyAssembly", | |
"Server": { | |
"Port": "44320", | |
"ServerCertificate": { | |
"StoreName": "My", | |
"StoreLocation": "LocalMachine", | |
"Thumbprint": "84ee508fb0e1cf7c0075e20a431b6166cffc572f" | |
}, | |
"ClientCertificates": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var serverCertificate = new Certificate { Thumbprint = "84ee508fb0e1cf7c0075e20a431b6166cffc572f" }; | |
var client = new EnclaveClient( | |
FindTestCertificate(), | |
pinnedCertificates: new[] { | |
serverCertificate | |
} | |
); | |
var key = await client.GenerateKey("rsa"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class KerberosEndToEndMiddleware | |
{ | |
private readonly SimpleKerberosValidator validator; | |
private readonly NextFunc next; | |
public KerberosEndToEndMiddleware(NextFunc next) | |
{ | |
this.next = next; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var secret = "P@ssw0rd!"; // => Encoding.Unicode.GetBytes(...) | |
var validator = new SimpleKerberosValidator(secret); | |
ClaimsIdentity identity = validator.Validate("YIIG6QYGKwYBBQUCoIIG3TCCBtmgMDAuBgkqhkiC9xI..."); | |
Debug.Assert(identity.Name == "user@domain.com"); |
NewerOlder