public void Remover(string userId) { try { var list = fabric_ca_client.GetHFCAIdentities(admin); var user = list.FirstOrDefault(x => x.EnrollmentId == userId); if (user != null) { var test = fabric_ca_client.NewHFCAIdentity(userId); var resp = test.Delete(admin); if (resp == 1) { if (File.Exists(Path.Combine(keyStorePath, userId))) { var file = SampleUser.Load(userId, keyStorePath); File.Delete(Path.Combine(keyStorePath, userId)); File.Delete(Path.Combine(keyStorePath, ((Enrollment)file.Enrollment).signingIdentity)); } } } } catch (Exception ex) { Console.WriteLine(ex); } }
public UserManager() { keyStorePath = @"D:\Projetos\Hyperledger\fabcar\hfc-key-store\"; admin = SampleUser.Load("admin", keyStorePath); fabric_client = HFClient.Create(); var crypto = new Hyperledger.Fabric.SDK.Security.CryptoPrimitives(); crypto.Init(); crypto.Store.AddCertificate(admin.Enrollment.Cert); fabric_client.CryptoSuite = crypto; fabric_client.UserContext = admin; channel = fabric_client.NewChannel("mychannel"); var peer = fabric_client.NewPeer("p1", $"grpc://{Startup.HyperleaderServer}:7051"); channel.AddPeer(peer); var ordered = fabric_client.NewOrderer("o1", $"grpc://{Startup.HyperleaderServer}:7050"); channel.AddOrderer(ordered); channel.Initialize(); fabric_ca_client = new Hyperledger.Fabric_CA.SDK.HFCAClient("", $"http://{Startup.HyperleaderServer}:7054", new Hyperledger.Fabric.SDK.Helper.Properties()); fabric_ca_client.CryptoSuite = crypto; }