Skip to content

Commit 3cbdd1b

Browse files
Merge pull request #4 from DevWizardHQ/fix/ssl-verification-default-false
fix: set SSL verification to false by default to prevent connection timeouts (#3)
2 parents f72ed03 + eff49d4 commit 3cbdd1b

File tree

8 files changed

+113
-13
lines changed

8 files changed

+113
-13
lines changed

config/textify.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
'sender_id' => env('DHOROLA_SENDER_ID'),
7272
'base_uri' => env('DHOROLA_BASE_URI', 'https://api.dhorolasms.net'),
7373
'timeout' => env('DHOROLA_TIMEOUT', 30),
74-
'verify_ssl' => env('DHOROLA_VERIFY_SSL', true),
74+
'verify_ssl' => env('DHOROLA_VERIFY_SSL', false),
7575
],
7676

7777
'bulksmsbd' => [
@@ -92,7 +92,7 @@
9292
'campaign_id' => env('MIMSMS_CAMPAIGN_ID'),
9393
'base_uri' => env('MIMSMS_BASE_URI', 'https://api.mimsms.com'),
9494
'timeout' => env('MIMSMS_TIMEOUT', 30),
95-
'verify_ssl' => env('MIMSMS_VERIFY_SSL', true),
95+
'verify_ssl' => env('MIMSMS_VERIFY_SSL', false),
9696
],
9797

9898
'esms' => [
@@ -101,7 +101,7 @@
101101
'sender_id' => env('ESMS_SENDER_ID'),
102102
'base_uri' => env('ESMS_BASE_URI', 'https://login.esms.com.bd'),
103103
'timeout' => env('ESMS_TIMEOUT', 30),
104-
'verify_ssl' => env('ESMS_VERIFY_SSL', true),
104+
'verify_ssl' => env('ESMS_VERIFY_SSL', false),
105105
],
106106

107107
'revesms' => [
@@ -113,7 +113,7 @@
113113
'base_uri' => env('REVESMS_BASE_URI', 'https://smpp.revesms.com:7790'),
114114
'balance_uri' => env('REVESMS_BALANCE_URI', 'https://smpp.revesms.com'),
115115
'timeout' => env('REVESMS_TIMEOUT', 30),
116-
'verify_ssl' => env('REVESMS_VERIFY_SSL', true),
116+
'verify_ssl' => env('REVESMS_VERIFY_SSL', false),
117117
],
118118

119119
'alphasms' => [
@@ -122,7 +122,7 @@
122122
'sender_id' => env('ALPHASMS_SENDER_ID'),
123123
'base_uri' => env('ALPHASMS_BASE_URI', 'https://api.sms.net.bd'),
124124
'timeout' => env('ALPHASMS_TIMEOUT', 30),
125-
'verify_ssl' => env('ALPHASMS_VERIFY_SSL', true),
125+
'verify_ssl' => env('ALPHASMS_VERIFY_SSL', false),
126126
],
127127

128128
// Global SMS Providers
@@ -141,7 +141,7 @@
141141
'from' => env('NEXMO_FROM', 'Vonage APIs'),
142142
'client_ref' => env('NEXMO_CLIENT_REF'), // Optional: Custom reference for tracking
143143
'timeout' => env('NEXMO_TIMEOUT', 30),
144-
'verify_ssl' => env('NEXMO_VERIFY_SSL', true),
144+
'verify_ssl' => env('NEXMO_VERIFY_SSL', false),
145145
],
146146
],
147147

src/Providers/Bangladeshi/AlphaSmsProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected function getClientConfig(): array
2020
return [
2121
'base_uri' => $this->config['base_uri'] ?? 'https://api.sms.net.bd',
2222
'timeout' => $this->config['timeout'] ?? 30,
23-
'verify' => $this->config['verify_ssl'] ?? true,
23+
'verify' => $this->config['verify_ssl'] ?? false,
2424
];
2525
}
2626

src/Providers/Bangladeshi/DhorolaSmsProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function getClientConfig(): array
2929
return [
3030
'base_uri' => $this->config['base_uri'] ?? 'https://api.dhorolasms.net',
3131
'timeout' => $this->config['timeout'] ?? 30,
32-
'verify' => $this->config['verify_ssl'] ?? true,
32+
'verify' => $this->config['verify_ssl'] ?? false,
3333
];
3434
}
3535

src/Providers/Bangladeshi/EsmsProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected function getClientConfig(): array
2020
return [
2121
'base_uri' => $this->config['base_uri'] ?? 'https://login.esms.com.bd',
2222
'timeout' => $this->config['timeout'] ?? 30,
23-
'verify' => $this->config['verify_ssl'] ?? true,
23+
'verify' => $this->config['verify_ssl'] ?? false,
2424
];
2525
}
2626

src/Providers/Bangladeshi/MimSmsProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected function getClientConfig(): array
2020
return [
2121
'base_uri' => $this->config['base_uri'] ?? 'https://api.mimsms.com',
2222
'timeout' => $this->config['timeout'] ?? 30,
23-
'verify' => $this->config['verify_ssl'] ?? true,
23+
'verify' => $this->config['verify_ssl'] ?? false,
2424
];
2525
}
2626

src/Providers/Bangladeshi/ReveSmsProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected function getClientConfig(): array
2020
return [
2121
'base_uri' => $this->config['base_uri'] ?? 'https://smpp.revesms.com:7790',
2222
'timeout' => $this->config['timeout'] ?? 30,
23-
'verify' => $this->config['verify_ssl'] ?? true,
23+
'verify' => $this->config['verify_ssl'] ?? false,
2424
];
2525
}
2626

@@ -140,7 +140,7 @@ public function getBalance(): float
140140
$balanceClient = new \GuzzleHttp\Client([
141141
'base_uri' => $balanceUri,
142142
'timeout' => $this->config['timeout'] ?? 30,
143-
'verify' => $this->config['verify_ssl'] ?? true,
143+
'verify' => $this->config['verify_ssl'] ?? false,
144144
]);
145145

146146
$response = $balanceClient->get('/sms/smsConfiguration/smsClientBalance.jsp', [

src/Providers/BaseProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ protected function getClientConfig(): array
9898
{
9999
return [
100100
'timeout' => $this->config['timeout'] ?? 30,
101-
'verify' => $this->config['verify_ssl'] ?? true,
101+
'verify' => $this->config['verify_ssl'] ?? false,
102102
];
103103
}
104104

tests/SslVerificationTest.php

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use DevWizard\Textify\Providers\Bangladeshi\AlphaSmsProvider;
6+
use DevWizard\Textify\Providers\Bangladeshi\DhorolaSmsProvider;
7+
use DevWizard\Textify\Providers\Bangladeshi\EsmsProvider;
8+
use DevWizard\Textify\Providers\Bangladeshi\MimSmsProvider;
9+
use DevWizard\Textify\Providers\Bangladeshi\ReveSmsProvider;
10+
11+
/**
12+
* Helper function to get client config using reflection
13+
*/
14+
function getClientConfig($provider): array
15+
{
16+
$reflection = new ReflectionClass($provider);
17+
$method = $reflection->getMethod('getClientConfig');
18+
$method->setAccessible(true);
19+
20+
return $method->invoke($provider);
21+
}
22+
23+
it('defaults SSL verification to false for all providers', function () {
24+
25+
// Test ReveSmsProvider
26+
$reveProvider = new ReveSmsProvider([
27+
'apikey' => 'test_key',
28+
'secretkey' => 'test_secret',
29+
'client_id' => 'test_client',
30+
]);
31+
$reveConfig = getClientConfig($reveProvider);
32+
expect($reveConfig['verify'])->toBeFalse();
33+
34+
// Test AlphaSmsProvider
35+
$alphaProvider = new AlphaSmsProvider([
36+
'api_key' => 'test_key',
37+
]);
38+
$alphaConfig = getClientConfig($alphaProvider);
39+
expect($alphaConfig['verify'])->toBeFalse();
40+
41+
// Test DhorolaSmsProvider
42+
$dhorolaProvider = new DhorolaSmsProvider([
43+
'api_key' => 'test_key',
44+
'sender_id' => 'test_sender',
45+
]);
46+
$dhorolaConfig = getClientConfig($dhorolaProvider);
47+
expect($dhorolaConfig['verify'])->toBeFalse();
48+
49+
// Test EsmsProvider
50+
$esmsProvider = new EsmsProvider([
51+
'api_token' => 'test_token',
52+
'sender_id' => 'test_sender',
53+
]);
54+
$esmsConfig = getClientConfig($esmsProvider);
55+
expect($esmsConfig['verify'])->toBeFalse();
56+
57+
// Test MimSmsProvider
58+
$mimProvider = new MimSmsProvider([
59+
'username' => 'test@example.com',
60+
'apikey' => 'test_key',
61+
]);
62+
$mimConfig = getClientConfig($mimProvider);
63+
expect($mimConfig['verify'])->toBeFalse();
64+
});
65+
66+
it('allows SSL verification to be explicitly enabled', function () {
67+
// Test that explicit verify_ssl=true works
68+
$reveProvider = new ReveSmsProvider([
69+
'apikey' => 'test_key',
70+
'secretkey' => 'test_secret',
71+
'client_id' => 'test_client',
72+
'verify_ssl' => true,
73+
]);
74+
$reveConfig = getClientConfig($reveProvider);
75+
expect($reveConfig['verify'])->toBeTrue();
76+
77+
// Test that explicit verify_ssl=false works
78+
$alphaProvider = new AlphaSmsProvider([
79+
'api_key' => 'test_key',
80+
'verify_ssl' => false,
81+
]);
82+
$alphaConfig = getClientConfig($alphaProvider);
83+
expect($alphaConfig['verify'])->toBeFalse();
84+
});
85+
86+
it('ensures ReveSmsProvider balance client also respects SSL verification setting', function () {
87+
// Create a provider with SSL verification disabled
88+
$provider = new ReveSmsProvider([
89+
'apikey' => 'test_key',
90+
'secretkey' => 'test_secret',
91+
'client_id' => 'test_client',
92+
'verify_ssl' => false,
93+
]);
94+
95+
// Verify the getBalance method exists
96+
expect(method_exists($provider, 'getBalance'))->toBeTrue();
97+
98+
// Verify that the provider is properly configured
99+
expect($provider)->toBeInstanceOf(ReveSmsProvider::class);
100+
});

0 commit comments

Comments
 (0)