public void DoKeyExchange(object peer) { try { PinIssuance.Net.Bridge.PostBridge.Client.Engine theEngine = new PinIssuance.Net.Bridge.PostBridge.Client.Engine(PinConfigurationManager.FepConfig.BridgeHostIp, PinConfigurationManager.FepConfig.InternalServerPort, "trx"); new PANE.ERRORLOG.Error().LogInfo("Sending key exchange . . . " + PinConfigurationManager.FepConfig.BridgeHostIp + ":" + PinConfigurationManager.FepConfig.InternalServerPort); KeyExchangeResponse response = theEngine.DoKeyExchange(); if (response == null) { new PANE.ERRORLOG.Error().LogInfo("Key exchange has No Response"); throw new ApplicationException("Key exchange has No Response"); } else if (response.SessionKey == null) { new PANE.ERRORLOG.Error().LogInfo("The Response for key exchange contained no Session key: response " + response.ResponseCode); throw new ApplicationException("The Response for key exchange contained no Session key "); } new PANE.ERRORLOG.Error().LogInfo("about to write to file "); File.WriteAllText(Path.Combine(PinConfigurationManager.HsmConfig.ZPKLocation, "zpk.key"), string.Format("{0}-{1}", response.SessionKey, response.CheckDigit)); new PANE.ERRORLOG.Error().LogInfo(string.Format("{0}-{1}", response.SessionKey, response.CheckDigit)); TranslateSessionKeyToStorageKey(Path.Combine(PinConfigurationManager.HsmConfig.ZPKLocation, "storage.key"), response.SessionKey); } catch (Exception e) { new PANE.ERRORLOG.Error().LogToFile(e); } finally { if (_keyExchangeTimer != null) { _keyExchangeTimer.Change(600000, Timeout.Infinite); } } }
public KeyExchangeResponse DoKeyExchange() { KeyExchangeResponse response = null; lock (this) { if (Connect()) { Console.WriteLine("connect"); KeyExchange keMsg = new KeyExchange(_transactionID); new PANE.ERRORLOG.Error().LogInfo("About to send key Exchange Message: " + keMsg.ToString()); Trx.Messaging.Message responseMessage = ProcessRequest(keMsg); response = new KeyExchangeResponse(responseMessage); new PANE.ERRORLOG.Error().LogInfo("Recieved Exchange Message: " + responseMessage.ToString()); response.TransactionID = _transactionID; } else { Console.WriteLine("not connected"); } } return(response); }