Skip to content

Commit 583f93a

Browse files
authored
Merge pull request #332 from timomayer/master
Feature: Add personal certificate support to connect to jira
2 parents 28e9760 + 87f4121 commit 583f93a

File tree

5 files changed

+104
-4
lines changed

5 files changed

+104
-4
lines changed

src/Configuration/AbstractConfiguration.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,38 @@ public function isCurlOptSslVerifyPeer()
197197
return $this->curlOptSslVerifyPeer;
198198
}
199199

200+
/**
201+
* @return string
202+
*/
203+
public function isCurlOptSslCert()
204+
{
205+
return $this->curlOptSslCert;
206+
}
207+
208+
/**
209+
* @return string
210+
*/
211+
public function isCurlOptSslCertPassword()
212+
{
213+
return $this->curlOptSslCertPassword;
214+
}
215+
216+
/**
217+
* @return string
218+
*/
219+
public function isCurlOptSslKey()
220+
{
221+
return $this->curlOptSslKey;
222+
}
223+
224+
/**
225+
* @return string
226+
*/
227+
public function isCurlOptSslKeyPassword()
228+
{
229+
return $this->curlOptSslKeyPassword;
230+
}
231+
200232
/**
201233
* @return bool
202234
*/
@@ -290,4 +322,4 @@ public function getUseV3RestApi()
290322
{
291323
return $this->useV3RestApi;
292324
}
293-
}
325+
}

src/Configuration/ArrayConfiguration.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public function __construct(array $configuration)
2323
$this->jiraLogLevel = 'WARNING';
2424
$this->curlOptSslVerifyHost = false;
2525
$this->curlOptSslVerifyPeer = false;
26+
$this->curlOptSslCert = '';
27+
$this->curlOptSslCertPassword = '';
28+
$this->curlOptSslKey = '';
29+
$this->curlOptSslKeyPassword = '';
2630
$this->curlOptVerbose = false;
2731
$this->cookieAuthEnabled = false;
2832
$this->cookieFile = 'jira-cookie.txt';
@@ -36,4 +40,4 @@ public function __construct(array $configuration)
3640
}
3741
}
3842
}
39-
}
43+
}

src/Configuration/ConfigurationInterface.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ public function isCurlOptSslVerifyHost();
6969
*/
7070
public function isCurlOptSslVerifyPeer();
7171

72+
/**
73+
* @return string
74+
*/
75+
public function isCurlOptSslCert();
76+
77+
/**
78+
* @return string
79+
*/
80+
public function isCurlOptSslCertPassword();
81+
82+
/**
83+
* @return string
84+
*/
85+
public function isCurlOptSslKey();
86+
87+
/**
88+
* @return string
89+
*/
90+
public function isCurlOptSslKeyPassword();
91+
7292
/**
7393
* Curl options CURLOPT_VERBOSE.
7494
*
@@ -138,4 +158,4 @@ public function getProxyPassword();
138158
* @return bool
139159
*/
140160
public function getUseV3RestApi();
141-
}
161+
}

src/Configuration/DotEnvConfiguration.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public function __construct($path = '.')
2929
$this->jiraLogLevel = $this->env('JIRA_LOG_LEVEL', 'WARNING');
3030
$this->curlOptSslVerifyHost = $this->env('CURLOPT_SSL_VERIFYHOST', false);
3131
$this->curlOptSslVerifyPeer = $this->env('CURLOPT_SSL_VERIFYPEER', false);
32+
$this->curlOptSslCert = $this->env('CURLOPT_SSL_CERT');
33+
$this->curlOptSslCertPassword = $this->env('CURLOPT_SSL_CERT_PASSWORD');
34+
$this->curlOptSslKey = $this->env('CURLOPT_SSL_KEY');
35+
$this->curlOptSslKeyPassword = $this->env('CURLOPT_SSL_KEY_PASSWORD');
3236
$this->curlOptUserAgent = $this->env('CURLOPT_USERAGENT', $this->getDefaultUserAgentString());
3337
$this->curlOptVerbose = $this->env('CURLOPT_VERBOSE', false);
3438
$this->proxyServer = $this->env('PROXY_SERVER');
@@ -156,4 +160,4 @@ private function loadDotEnv($path)
156160
throw new JiraException('can not load PHP dotenv class.!');
157161
}
158162
}
159-
}
163+
}

src/JiraClient.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,19 @@ public function exec($context, $post_data = null, $custom_request = null, $cooki
239239

240240
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->getConfiguration()->isCurlOptSslVerifyHost());
241241
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->getConfiguration()->isCurlOptSslVerifyPeer());
242+
if($this->getConfiguration()->isCurlOptSslCert()) {
243+
curl_setopt($ch, CURLOPT_SSLCERT, $this->getConfiguration()->isCurlOptSslCert());
244+
}
245+
if($this->getConfiguration()->isCurlOptSslCertPassword()) {
246+
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $this->getConfiguration()->isCurlOptSslCertPassword());
247+
}
248+
if($this->getConfiguration()->isCurlOptSslKey()) {
249+
curl_setopt($ch, CURLOPT_SSLKEY, $this->getConfiguration()->isCurlOptSslKey());
250+
}
251+
if($this->getConfiguration()->isCurlOptSslKeyPassword()) {
252+
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $this->getConfiguration()->isCurlOptSslKeyPassword());
253+
}
254+
242255
curl_setopt($ch, CURLOPT_USERAGENT, $this->getConfiguration()->getCurlOptUserAgent());
243256

244257
// curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set
@@ -341,6 +354,19 @@ private function createUploadHandle($url, $upload_file, $ch)
341354
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->getConfiguration()->isCurlOptSslVerifyHost());
342355
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->getConfiguration()->isCurlOptSslVerifyPeer());
343356

357+
if($this->getConfiguration()->isCurlOptSslCert()) {
358+
curl_setopt($ch, CURLOPT_SSLCERT, $this->getConfiguration()->isCurlOptSslCert());
359+
}
360+
if($this->getConfiguration()->isCurlOptSslCertPassword()) {
361+
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $this->getConfiguration()->isCurlOptSslCertPassword());
362+
}
363+
if($this->getConfiguration()->isCurlOptSslKey()) {
364+
curl_setopt($ch, CURLOPT_SSLKEY, $this->getConfiguration()->isCurlOptSslKey());
365+
}
366+
if($this->getConfiguration()->isCurlOptSslKeyPassword()) {
367+
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $this->getConfiguration()->isCurlOptSslKeyPassword());
368+
}
369+
344370
$this->proxyConfigCurlHandle($ch);
345371

346372
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); cannot be activated when an open_basedir is set
@@ -548,6 +574,20 @@ public function download($url, $outDir, $file, $cookieFile = null)
548574

549575
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->getConfiguration()->isCurlOptSslVerifyHost());
550576
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->getConfiguration()->isCurlOptSslVerifyPeer());
577+
578+
if($this->getConfiguration()->isCurlOptSslCert()) {
579+
curl_setopt($ch, CURLOPT_SSLCERT, $this->getConfiguration()->isCurlOptSslCert());
580+
}
581+
if($this->getConfiguration()->isCurlOptSslCertPassword()) {
582+
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $this->getConfiguration()->isCurlOptSslCertPassword());
583+
}
584+
if($this->getConfiguration()->isCurlOptSslKey()) {
585+
curl_setopt($ch, CURLOPT_SSLKEY, $this->getConfiguration()->isCurlOptSslKey());
586+
}
587+
if($this->getConfiguration()->isCurlOptSslKeyPassword()) {
588+
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $this->getConfiguration()->isCurlOptSslKeyPassword());
589+
}
590+
551591
$this->proxyConfigCurlHandle($ch);
552592

553593
// curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set

0 commit comments

Comments
 (0)