Minor improvements

- WebFinger:  detect when to use http or https, better function naming
- RequestPool: add user agent
This commit is contained in:
2024-02-21 15:39:41 -03:00
parent 166f428cd1
commit 7fbdd031ff
5 changed files with 76 additions and 20 deletions

View File

@@ -3,6 +3,11 @@ module util;
import std.format;
import std.json;
import slf4d;
import deimos.openssl.rsa;
import deimos.openssl.pem;
void optional(T)(ref JSONValue val, string key, ref T receiver) {
const(JSONValue)* p = key in val;
@@ -24,3 +29,18 @@ T optional(T)(ref JSONValue val, string key) {
void required(T)(ref JSONValue val, string key, ref T receiver) {
receiver = val[key].get!T;
}
void generateRSA() {
RSA* rsa = RSA_generate_key(2048, 3, null, null);
BIO* bio = BIO_new(BIO_s_mem());
PEM_write_bio_RSAPrivateKey(bio, rsa, null, null, 0, null, null);
int keyLen = BIO_pending(bio);
char[] pemKey = new char[keyLen + 1];
BIO_read(bio, pemKey.ptr, keyLen);
BIO_free_all(bio);
RSA_free(rsa);
infoF!"private key: %s"(pemKey);
}