Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix certificate testing, and allowing RSA certs as well as pkcs12 #72

Closed
wants to merge 11 commits into from
3 changes: 2 additions & 1 deletion modules/os2forms_digital_post/src/Form/SettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ public function submitForm(array &$form, FormStateInterface $formState): void {
private function testCertificate(): void {
try {
$certificateLocator = $this->certificateLocatorHelper->getCertificateLocator();
$certificateLocator->getCertificates();
$certificate = $this->settings->getCertificate();
($certificate[CertificateLocatorHelper::LOCATOR_TYPE_FILE_SYSTEM]['path'] != NULL) ? $certificateLocator->getCertificate() : $certificateLocator->getCertificates();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code need some commenting, it take a while to process these two lines.

When you're using condition, it is preferred to use if structure, a shortened notation of a condition used when assigning the variable.

I don't think that the code servers the purpose now - before we checked of the cetificate can read by openssl_pkcs12_read, however now the test will pass even when cerificate file is simply present in the system:
$certificateLocator->getCertificate() is simply checking if there is a file with such name.

$this->messenger()->addStatus($this->t('Certificate succesfully tested'));
}
catch (\Throwable $throwable) {
Expand Down