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

[FEATURE] #54 Add Open SSL encrypted transport decryption #182

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
40 changes: 40 additions & 0 deletions Classes/Domain/Model/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ class Client extends AbstractEntity
* @TYPO3\CMS\Extbase\Annotation\ORM\Lazy
*/
protected $tag = null;
/**
* @var string
*/
protected $publicKey = null;
/**
* @var string
*/
protected $cipher = null;

/**
* __construct
Expand Down Expand Up @@ -740,6 +748,38 @@ public function setTag(Tag $tag)
$this->tag = $tag;
}

/**
* @return string
*/
public function getPublicKey()
{
return $this->publicKey;
}

/**
* @param string $publicKey
*/
public function setPublicKey($publicKey)
{
$this->publicKey = $publicKey;
}

/**
* @return string
*/
public function getCipher(): string
{
return $this->cipher;
}

/**
* @param string $cipher
*/
public function setCipher(string $cipher): void
{
$this->cipher = $cipher;
}

/**
* @return array
*/
Expand Down
13 changes: 11 additions & 2 deletions Classes/Service/Import/ClientImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ public function __construct()
}

/**
* @param int $clientId
* @param int|null $clientId
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function run(int $clientId = 0)
public function run(int $clientId = null)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable(self::TABLE);
Expand Down Expand Up @@ -212,6 +212,15 @@ protected function requestClientData(array $row)
}
if (in_array($response->getStatusCode(), [ 200, 301, 302 ], true)) {
$response = $response->getBody()->getContents();
if (
!empty($row['public_key'])
&& !empty($row['cipher'])
&& in_array($row['cipher'], openssl_get_cipher_methods())
) {
try {
$response = openssl_decrypt($response, 'aes', $row['public_key']);
} catch (\Exception $e) {}
}
}

return $response;
Expand Down
14 changes: 14 additions & 0 deletions Configuration/TCA/tx_t3monitoring_domain_model_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
1 => [
'showitem' => '
--div--;General,--palette--;;paletteTitle, --palette--;;paletteDomain,email,sla,tag,
--div--;SSL,--palette--;;paletteSecureConnection,
--div--;Readonly information,last_successful_import,error_message,--palette--;;paletteCore, --palette--;;paletteExtensions, --palette--;;paletteVersions, --palette--;;paletteDiskSpace,
--div--;Extra,extra_info,extra_warning,extra_danger,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
Expand All @@ -34,6 +35,7 @@
'paletteDomain' => ['showitem' => 'domain, secret, --linebreak--, basic_auth_username, basic_auth_password, host_header, --linebreak--, ignore_cert_errors, force_ip_resolve'],
'paletteVersions' => ['showitem' => 'php_version, mysql_version'],
'paletteDiskSpace' => ['showitem' => 'disk_total_space, disk_free_space'],
'paletteSecureConnection' => ['showitem' => 'public_key,--linebreak--,cipher']
],
'columns' => [
'hidden' => [
Expand Down Expand Up @@ -296,5 +298,17 @@
'minitems' => 0,
],
],
'public_key' => [
'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_client.public_key',
'config' => [
'type' => 'text'
]
],
'cipher' => [
'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_client.cipher',
'config' => [
'type' => 'input'
]
],
],
];
8 changes: 8 additions & 0 deletions Resources/Private/Language/de.locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
<source>Sla</source>
<target>Sla</target>
</trans-unit>
<trans-unit id="tx_t3monitoring_domain_model_client.public_key">
<source>Public key for client</source>
<target>Öffentlicher Schlüssel des Client</target>
</trans-unit>
<trans-unit id="tx_t3monitoring_domain_model_client.cipher">
<source>OpenSSL cipher from client</source>
<target>OpenSSL Verschlüsselungsmethode des Client</target>
</trans-unit>
<trans-unit id="tx_t3monitoring_domain_model_extension">
<source>Extension</source>
<target>Extension</target>
Expand Down
6 changes: 6 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@
<trans-unit id="tx_t3monitoring_domain_model_client.tag">
<source>Tag</source>
</trans-unit>
<trans-unit id="tx_t3monitoring_domain_model_client.public_key">
<source>Public key for client</source>
</trans-unit>
<trans-unit id="tx_t3monitoring_domain_model_client.cipher">
<source>OpenSSL cipher from client</source>
</trans-unit>
<trans-unit id="tx_t3monitoring_domain_model_extension">
<source>Extension</source>
</trans-unit>
Expand Down
3 changes: 3 additions & 0 deletions ext_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ CREATE TABLE tx_t3monitoring_domain_model_client (
sla int(11) unsigned DEFAULT '0',
tag tinytext,

public_key text,
cipher varchar(20) default '' not null,

tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
Expand Down