public static bool GetCertificate(string taskCode) { //Registration.ClientRegistrar.Logger.Info("Enter"); StateObject stateObj = null; try { stateObj = new StateObject(); TCPSocket.ConnectIgnoreCertError(stateObj); stateObj.ClientStream.AuthenticateAsClient(m_domainName); // byte[] bodyBytes = Encoding.ASCII.GetBytes(""); byte[] headerBytes = BuildHeaders(taskCode, 0); TcpUtil.WriteHeaderData(stateObj.ClientStream, headerBytes); //TcpUtil.WriteData(stateObj.ClientStream, bodyBytes); byte[] bytesOfCert = TcpUtil.ReadDataAsBytes(stateObj.ClientStream); Registration.CertHandler.InstallConsoleServerCertificate(bytesOfCert); } catch (Exception ex) { //Registration.ClientRegistrar.Logger.Error(ex); return(false); } finally { stateObj.Close(); } //Registration.ClientRegistrar.Logger.Info("Exit"); return(true); }