how can openssl have SUCH a bad cli interface
cargo devel CI / cargo CI (push) Successful in 2m31s Details

This commit is contained in:
Christoph J. Scherr 2024-01-24 15:38:24 +01:00
parent cc80d0afae
commit 06430ec6b7
Signed by: cscherrNT
GPG Key ID: 8E2B45BC51A27EA7
9 changed files with 91 additions and 88 deletions

View File

@ -0,0 +1,24 @@
-----BEGIN CERTIFICATE-----
MIIEFDCCAvygAwIBAgITfl3NbK3jOj2V0yehJ0VkuBWlvDANBgkqhkiG9w0BAQsF
ADCBmTELMAkGA1UEBhMCREUxHTAbBgNVBAgMFEJhZGVuIFfDg8K8cnR0ZW1iZXJn
MREwDwYDVQQHDAhNYW5uaGVpbTEVMBMGA1UECgwMTmV0cG9uZyBUZWFtMR0wGwYD
VQQDDBROZXRwb25nLVRlc3QtQ0EgUm9vdDEiMCAGCSqGSIb3DQEJARYTc29mdHdh
cmVAY3NjaGVyci5kZTAeFw0yNDAxMjQxNDM3NTdaFw0zNDAxMjExNDM3NTdaMIGZ
MQswCQYDVQQGEwJERTEdMBsGA1UECAwUQmFkZW4gV8ODwrxydHRlbWJlcmcxETAP
BgNVBAcMCE1hbm5oZWltMRUwEwYDVQQKDAxOZXRwb25nIFRlYW0xHTAbBgNVBAMM
FE5ldHBvbmctVGVzdC1DQSBSb290MSIwIAYJKoZIhvcNAQkBFhNzb2Z0d2FyZUBj
c2NoZXJyLmRlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjc443jjU
YZP4aVC0vD0WRpzC6G50wva3lLX2vOf6x1xAE/sVQ7F3j25s/oUUzHSf4/F4H3rC
R5ZmpyOBiW/1ZuQVb48HxzE7Vh/QQenTUVcPEdZcqf0vLogDzaSrq9uMXvmWHWgQ
IE0yYbEBd2/bE0k530EW5QZpKdUZI6m+Tf6k60Fk65skC4IZ684M6ahB9AQiBY0c
6DzJPN6AV33s6HjHqLJUeWwiEFXx7v/I3Fo81NHnoRZQw9bNel3rRa1Ovn1FIUz3
rKygXb3/Zcl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QSdeD7Tke5Ywzc/LHqNhTJjnDjJCY
xWzDRe/ALUHCEEc4C6dd5qPmD30T8Fb8fRX6HVFHqT3VKb3KKrpZYvkNY8ihprq6
iLDnm4a9JQ3aGrzkgV6xxlo=
-----END PRIVATE KEY-----

31
data/ca.conf Normal file
View File

@ -0,0 +1,31 @@
[ ca ]
default_ca = Netpong-Test-CA # The default ca section
[ Netpong-Test-CA ]
dir = ./Netpong-Test-CA # top dir
database = $dir/index.txt # index file.
new_certs_dir = $dir/newcerts # new certs dir
certificate = $dir/cacert.pem # The CA cert
serial = $dir/serial # serial no file
private_key = $dir/private/cakey.pem# CA private key
RANDFILE = $dir/private/.rand # random number file
default_days = 3650 # how long to certify for
default_crl_days= 30 # how long before next CRL
policy = policy_any # default policy
email_in_dn = no # Don't add the email into cert DN
name_opt = ca_default # Subject name display option
cert_opt = ca_default # Certificate display option
copy_extensions = none # Don't copy extensions from request
[ policy_any ]
countryName = optional
stateOrProvinceName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
emailAddress = optional

View File

@ -1,21 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDazCCAlOgAwIBAgIUPLZFd1ZmncG0bzFIhFBfxj7kKEMwDQYJKoZIhvcNAQEL
BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yNDAxMjEyMTAzMTJaFw0yNDAy
MjAyMTAzMTJaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw
HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB
AQUAA4IBDwAwggEKAoIBAQCyGMplbAbVnxqpxGOBCjUeZUQ/V7PmPFLPnjhUIOb5
UBXt3aNE5qrL8VIUTia8ljv/1Ma3c+468e2c0BRv++Jvgbzi/LEAQfADapBz5ZD8
vg3w0l7il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5XbkfvYaLN
2CqSMg3C+Vqord4zWEI9WIA8jH0yaw6eocVt21o6iXEXj15gaEW7KiEQBks12/fT
Hni7uU8g+bRPq2jX1S2KjuoHqdk2RrtjQDqj2xUCgYEAnITvoy6U427XGIH010bn
+O5dfgsZ0XEoaxJRYQdO4Tp6Ob/lKQDGmuu9ehbfMjaFR0uAWvsW/rps7P1WTl/b
LtArkTXtxe2kNOKb7wbChtiIYyghtRk9QLAZzDP/bc83denwjVg0mkbcynMCfeJg
ILvGfJEt28Dwf1StGv/fzI8=
-----END PRIVATE KEY-----

View File

@ -1,26 +0,0 @@
import socket
def ping():
HOST = "127.0.0.1"
PORT = 9999
payload = b"ping\0"
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
while True:
try:
s.sendall(payload)
print("> ping")
except Exception as e:
break
reply = s.recv(1024).decode()
if reply == "":
break
print(f"< {reply}")
print("connection shut down")
if __name__ == "__main__":
ping()

5
scripts/make_cert.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
mkdir data
echo create ca
# non-interactive and 10 years expiration
openssl req -x509 -nodes -newkey rsa:4096 -keyout data/key.pem -out data/cert.pem -sha256 -days 3650 -subj '/CN=localhost'

View File

@ -1,12 +0,0 @@
const MAX: usize = 50;
use std::process::Command;
fn main() {
let mut pool = ThreadPool::new(MAX);
loop {
pool.execute(||{
Command::new("python3").args(["scripts/client.py"]).output().unwrap();
});
}
}

View File

@ -4,7 +4,7 @@ use std::{fs::File, io::BufReader, sync::Arc};
use crate::{common::decode, Config};
use anyhow;
use libpt::log::{error, info};
use libpt::log::{error, info, trace};
use rustls_pemfile::certs;
use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
@ -32,9 +32,11 @@ impl Client {
if cfg.certs.is_some() {
let mut reader = BufReader::new(File::open(cfg.certs.clone().unwrap())?);
for cert in certs(&mut reader) {
trace!("found custom cert: {cert:?}");
root_cert_store.add(cert?)?
}
}
trace!("root cert store: {root_cert_store:?}");
let tls_config = rustls::ClientConfig::builder()
.with_root_certificates(root_cert_store)
.with_no_client_auth();