func TestConnection(address string)(certsReturn string){
conf := &tls.Config{
InsecureSkipVerify: true,
}
var err error
conn, err := tls.DialWithDialer(&net.Dialer{Timeout: 10})
if err != nil {
certsReturn = "0"
return
}else{
certs := conn.ConnectionState().PeerCertificates
for _, cert := range certs {
certsReturn = certsReturn+cert.Issuer.String()+"\n"
fmt.Println("Host:", address, "Issuer:", cert.Issuer))}
import socket
import ssl
def test_connection(address):
certs_return = ""
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
try:
with socket.create_connection((address, 443), timeout=10) as sock:
with context.wrap_socket(sock, server_hostname=address) as ssock:
cert = ssock.getpeercert()
for (issuer, entry) in cert['issuer']:
certs_return += "{}={}\n".format(issuer, entry)
except Exception as e:
certs_return = "0"
return certs_return