4,103 questions
Need Help In Connecting TLS/SSL Connection with CA_Chain Certificate, Client Certificate and Private Key in .Net c#
Anonymous
i need to connect with HSM with a IP and Port, and it will open a TLS/SSL TCP connection, before handshaking it need to add certificate to authanticate.i received python code for sample to connect with it. but i need that part in .net/.net core c#.
Here is few line of code of python that i need in c#:
# Create socket
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.settimeout(2.000)
# Get the script directory so certificates can be loaded
certFolder = os.path.abspath(os.path.dirname(sys.argv[0]))
# Create the TLS context
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
if args.hsm_type.upper() == 'A':
context.set_ciphers("AES256-GCM-SHA384")
# Do not check the hostname when verifying the server certificate
context.check_hostname = False
# Load certificates and private key
context.load_verify_locations(certFolder + "/CA_MYHSM_chain.crt")
context.load_cert_chain(certfile=certFolder + "/client_MYHSM.crt", keyfile=certFolder + "/client_MYHSM.key")
# Wrap socket into TLS socket
with context.wrap_socket(sock) as ssock:
ssock.connect((args.host, int(args.port)))
Developer technologies .NET Other
Developer technologies C#
11,567 questions
Sign in to answer