Thanks, guys, I ended up using the trust password, but I have stumbled upon another error, no matter what I do, I always get:
Invalid certificate type
.
I don’t know what I am doing wrong, here is how I am generating the pem cert and key in PHP:
$days = $config['days'] ?? 365;
$dn = [
"organizationName" => AppConfig::getAppName(),
"commonName" => AppConfig::getAppName(),
"emailAddress" => MailConfig::getMailReplyTo()
];
// Generate certificate
$privateKey = openssl_pkey_new();
$cert = openssl_csr_new($dn, $privateKey);
$cert = openssl_csr_sign($cert, null, $privateKey, $days);
// Generate strings
openssl_x509_export($cert, $certString);
openssl_pkey_export($privateKey, $privateKeyString);
Yes, it successfully connects to the server, the way I knew that was if I changed the password, I get unauthorized access, the only error I have is adding the cert, here is my payload (don’t worry, this is a fake pass):
{"name":"devsrealm","password":"epbBUvhO3laWWQAUTOuK6k0xlP2Cc8S\/UC+ZWY6aoFHw=="}
According to the doc:
The certificate field can be omitted in which case the TLS client
certificate in use for the connection will be retrieved and added to the
trust store.
even when I added the pem content, I still got the same error, here is the curl config (shorten it so I can get my point across):
$post_fields = json_encode($opts);
$curl_info = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => $this->timeout,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTPHEADER => ['Content-Type:application/json'],
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_SSLCERT_BLOB => $this->getCertificateString(),
CURLOPT_SSLKEY_BLOB => $this->getPrivateKeyString(),
CURLOPT_POSTFIELDS => $post_fields,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
];
The getCertificateString()
and getPrivateKeyString()
method is the ones generated above.
Between, I have verified that the pem file can be read by OpenSSL using openssl_x509_read
, and it did so with no error, so, I don’t know where the error is coming from.
Can anyone spot any errors?
Edit:
I generated the cert and key manually just to satisfy my curiosity, and I had the same error, where is the log file for a remote connection like this stored in lxd?
Edit1:
When I used an incorrect password, I can see that in the log, It shows:
“msg=Bad trust password”
so, correcting the password do not show any error but I still got the usual: “Invalid Certificate Type”