private string getCerter(string ruta) { string certdigital = ""; Chilkat.Cert certificado = new Chilkat.Cert(); ///verifica que sea un certificado debuelbe un true bool es_certificado = certificado.LoadFromFile(ruta); if (es_certificado) { int revocado = certificado.CheckRevoked(); string larg_numcer = certificado.SerialNumber; if (revocado == 1) { MessageBox.Show("Certificado Revocado"); } else { certdigital = certificado.ExportCertPem(); certdigital = certdigital.Replace("-----BEGIN CERTIFICATE-----", ""); certdigital = certdigital.Replace("-----END CERTIFICATE-----", ""); certdigital = certdigital.Replace("\r\n", ""); } } else { MessageBox.Show("No es certificado"); } return(certdigital); }
static void Main(string[] args) { Chilkat.Global glob = new Chilkat.Global(); bool success = glob.UnlockBundle("Anything for 30-day trial"); if (success != true) { Debug.WriteLine(glob.LastErrorText); return; } int status = glob.UnlockStatus; if (status == 2) { Debug.WriteLine("Unlocked using purchased unlock code."); } else { Debug.WriteLine("Unlocked in trial mode."); } // The LastErrorText can be examined in the success case to see if it was unlocked in // trial more, or with a purchased unlock code. Debug.WriteLine(glob.LastErrorText); var certPath = $@"{AppDomain.CurrentDomain.BaseDirectory}server_20110101.pfx"; var server = "83.220.246.39"; var port = 9000; var maxWaitMillisec = 10000; //var certPass = "******"; using (var socket = new Chilkat.Socket { SocksHostname = server, SocksPort = port, SocksUsername = "******", SocksPassword = "******", SocksVersion = 5, MaxReadIdleMs = maxWaitMillisec, MaxSendIdleMs = maxWaitMillisec }) { var cert = new Chilkat.Cert(); cert.LoadFromFile(certPath); socket.SetSslClientCert(cert); socket.Connect(server, port, true, maxWaitMillisec); var receivedString = socket.ReceiveString(); Console.WriteLine(receivedString ?? "none"); } }