Minor improvements
- WebFinger: detect when to use http or https, better function naming - RequestPool: add user agent
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user