Last active
June 25, 2020 11:36
-
-
Save technige/9f909489cc0964606915b645ca7449ec to your computer and use it in GitHub Desktop.
Tests for OCSP stapling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tech.nige.demo; | |
import javax.net.ssl.SSLContext; | |
import javax.net.ssl.SSLSocket; | |
import java.io.IOException; | |
import java.net.InetSocketAddress; | |
import java.security.NoSuchAlgorithmException; | |
import java.security.cert.Certificate; | |
public class SocketDemo { | |
public static void main(String... args) throws NoSuchAlgorithmException, IOException { | |
SSLContext ssl = SSLContext.getDefault(); | |
SSLSocket ss = (SSLSocket) ssl.getSocketFactory().createSocket(); | |
InetSocketAddress address = new InetSocketAddress("py2neo.org", 443); | |
ss.connect(address); | |
Certificate[] certs = ss.getSession().getPeerCertificates(); | |
for (Certificate cert : certs) { | |
System.out.println(cert); | |
} | |
ss.close(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {connect} from "tls"; | |
const host = "py2neo.org"; | |
const port = 443; | |
const ss = connect(port, host, {"servername": host}, () => { | |
console.log(ss.getPeerCertificate(true)); | |
ss.end(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pprint import pprint | |
from socket import create_connection | |
from ssl import SSLContext, CERT_REQUIRED | |
host = "py2neo.org" | |
port = 443 | |
ctx = SSLContext() | |
ctx.verify_mode = CERT_REQUIRED | |
ctx.load_default_certs() | |
ss = ctx.wrap_socket(create_connection((host, port)), server_hostname=host) | |
pprint(ss.getpeercert()) | |
ss.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment