Created
February 7, 2021 17:54
-
-
Save benob/f236f997b80c2664a757b79c988c0cd1 to your computer and use it in GitHub Desktop.
Nim server that checks client identity
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 net | |
var | |
sslContext = newContext(certFile = "fullchain.pem", keyFile = "privkey.pem", verifyMode = CVerifyPeer) | |
socket = newSocket(domain = AF_INET6) | |
socket.setSockOpt(OptReuseAddr, true) | |
socket.setSockOpt(OptReusePort, false) | |
socket.bindAddr(Port(1965), "::") | |
socket.listen() | |
sslContext.wrapSocket(socket) | |
while true: | |
var | |
client: Socket | |
socket.accept(client) | |
echo client.getPskIdentity() | |
echo client.getPeerCertificates() | |
client.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment