user2455079
user2455079

Reputation: 418

How to disable ssl check in fsockopen ? (PHP 5.6)

Upgraded PHP to 5.6.5 and got errors with fsockopen:

fsockopen('ssl://74.201.154.90', '465', $errno, $error, $this->timeout);

Warning: fsockopen(): Peer certificate CN=*.zoho.com' did not match expected CN=74.201.154.90' in ...

Warning: fsockopen(): Failed to enable crypto in ...

Warning: fsockopen(): unable to connect to ssl://74.201.154.90:465

Upvotes: 2

Views: 3538

Answers (2)

lospejos
lospejos

Reputation: 1986

I should mention, there are two points in this question and answers: 1). What was the cause of this ssl error and what you should to do to avoid it? Right answer is: the cause was certificate and host name mismatch, you should try to avoid setting IP address instead of host name to avoid such errors (and avoid MiTM attacks among others), this is a good practice; 2). What should I specify in PHP file to disable certificate validation? I know this is a poor practice but I want to know how exactly disable this validation.

Upvotes: 2

user4880112
user4880112

Reputation:

fsockopen('ssl://74.201.154.90', '465', $errno, $error, $this->timeout);

Try replacing 74.201.154.90 with smtp.zoho.com. That should do the trick.

Upvotes: 3

Related Questions