SSL_EXPIRE_DAY!
인증하시는 분들께는 상당히 유용하실 듯.
---------------------------------------------------
유징해야 하는 것들.
using System;
using System.Net;
using System.Net.Sockets;
using System.Net.Security;
using System.Security.Authentication;
using System.Collections;
using System.Security.Cryptography.X509Certificates;
using System.IO;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
---------------------------------------------------
Main 함수
// 객체 생성 //
// url 과 포트를 입력 받는다.
cExpire myExpire();
//
class CExpire
{
public CExpire()
{
// 초기화 할 것들 입력.
// 전 딱히 없네요.
}
public void GetInformation(string url, int port)
{
try
{
ConnectToSite(url,port);
}catch(Exception e)
{
Console.Error.WriteLine(e.Message);
}
}
public static void ConnectToSite(string servername , int port)
{
TcpClient client = new TcpClient(servername, port);
// 콜백 부분은 잘 조정하면 될듯..
SslStream sslStream = new SslStream(client.GetStream(), false,
new RemoteCertificateValidationCallback(ValidateServerCertificate) , null );
try
{
sslStream.AuthenticateAsCliet(servername);
}catch(AuthenticationException e)
{
client.Close();
return ;
}
}
private static bool ValidateServerCertificate ( object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors
)
{
Console.WriteLine("Subject : {0}\n", certificate.Subject);
Console.WriteLine("Subject : {0}\n", certificate.Issuer);
Console.WriteLine("Subject : {0}\n", certificate.GetSerialNumberString());
Console.WriteLine("Subject : {0}\n", certificate.GetExpirationDateString());
return true;
}
}
}

