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

Undo all of my previous changes #75

Merged
merged 7 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ before starting to add changes. Use example [placed in the end of the page](#exa
- [#73](https://github.com/OS2Forms/os2forms/pull/73a)
Fix issue with nested elements in webform inherit
- [#72](https://github.com/OS2Forms/os2forms/pull/72)
Fix certificate testing, also testing for RSA/PEM certs as well as PKCS12
Closed this pull request, and undid changes in develop
inuitviking marked this conversation as resolved.
Show resolved Hide resolved

## [3.13.2] 2023-10-19

Expand Down Expand Up @@ -187,4 +187,4 @@ before starting to add changes. Use example [placed in the end of the page](#exa
[Unreleased]: https://github.com/OS2Forms/os2forms/compare/3.5.0...HEAD
[3.5.0]: https://github.com/OS2Forms/os2forms/compare/3.2.5...3.5.0
[3.2.6]: https://github.com/OS2Forms/os2forms/compare/3.2.5...3.2.6
[3.2.5]: https://github.com/OS2Forms/os2forms/compare/3.2.4...3.2.5
[3.2.5]: https://github.com/OS2Forms/os2forms/compare/3.2.4...3.2.5
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@
"tecnickcom/tcpdf": "~6",
"webmozart/path-util": "^2.3",
"wsdltophp/packagebase": "^5.0",
"zaporylie/composer-drupal-optimizations": "^1.2",
"ext-openssl": "*"
},
"zaporylie/composer-drupal-optimizations": "^1.2"
},
inuitviking marked this conversation as resolved.
Show resolved Hide resolved
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"drupal/coder": "^8.3",
Expand Down
23 changes: 2 additions & 21 deletions modules/os2forms_digital_post/src/Form/SettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,27 +258,8 @@ public function submitForm(array &$form, FormStateInterface $formState): void {
private function testCertificate(): void {
try {
$certificateLocator = $this->certificateLocatorHelper->getCertificateLocator();
$certificatePath = $this->settings->getCertificate()[CertificateLocatorHelper::LOCATOR_TYPE_FILE_SYSTEM]['path'];

// Check if the certificate has the pkcs12 extension or not.
if (pathinfo($certificatePath, PATHINFO_EXTENSION) == 'pkcs12') {
// Check the certificate if it is a valid pkcs12 certificate.
$certificateLocator->getCertificates();
}
else {
// Get contents of certificate.
$certificateKeyFile = $certificateLocator->getCertificate();
// Create an array for checking the key with the certificate.
$keyCheckData = [$certificateKeyFile, $certificateLocator->getPassphrase()];
// Check the private key against the certificate.
$result = openssl_x509_check_private_key($certificateKeyFile, $keyCheckData);
// If the result is not "1", throw an exception.
if ($result != 1) {
throw new \ErrorException('PEM certificate is not valid.');
}
}

$this->messenger()->addStatus($this->t('Certificate successfully tested'));
$certificateLocator->getCertificates();
$this->messenger()->addStatus($this->t('Certificate succesfully tested'));
}
catch (\Throwable $throwable) {
$message = $this->t('Error testing certificate: %message', ['%message' => $throwable->getMessage()]);
Expand Down
1 change: 1 addition & 0 deletions src/Form/SettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
}

$this->messenger()->addStatus($this->t('The configuration options have been saved.'));

stankut marked this conversation as resolved.
Show resolved Hide resolved
}

}
Loading