I'm currently creating a small PHP script (vanilla PHP w/ WordPress) to check if an SSL is valid and trusted. I'm just getting input from the user for their URL. I was wondering if there is any known APIs that I can use to check if the SSL date is valid and if it is trusted? If not, is there any way to accomplish this in raw PHP instead of an API?
-
2This might be useful: https://stackoverflow.com/a/41398559/747744 – Eugene Primako Jul 02 '18 at 19:41
-
1or this https://stackoverflow.com/questions/3081042/how-to-get-ssl-certificate-info-with-curl-in-php – Tom Jul 02 '18 at 19:42
-
You already check that. Each time you make a https request. That's something that you can check with curl. – Federkun Jul 02 '18 at 19:43
-
Your question is not clear. What is "URLs SSL"? You mean an `https://` request? That is using TLS, stop repeating the error SSL that everyone does. Also what do you want to check to see if it is valid? You mean if the X.509 certificates used to authentify the TLS connection are valid? – Patrick Mevzek Jul 02 '18 at 19:45
2 Answers
It already does validation by default. You have to actively disable the validation for curl to work with an invalid ssl certificate.
So yes you can with a basic curl check. You can go even further and inspect the results of it by following through this excellent write up which gives you the SSL information if you want to experiment.
You might be better off using something like guzzle to manage this for you. SSL certificates like anything that offers 'security' is never actually 100% secure - there is ways to falsify ssl certificates but they tend to be very difficult to achieve and for your use case I think overkill.

- 1,719
- 13
- 19
-
Thanks! I wasn't aware that curl already validates the SSL for me. Rather I thought it had just checked if the URL was HTTPS. – ItsMichael Jul 02 '18 at 20:07
-
@ItsMichael Curl is in my opinion one of the best and most comprehensive libraries and is used by so many different languages and systems. Because of its transferable information I suggest you take a look https://curl.haxx.se/ (official curl library). Once you know the jist of curl the implementation of other languages is relatively straight forward. – Ne Ma Jul 02 '18 at 20:11
This API works really well. https://rapidapi.com/digicatech/api/check-ssl/ Free up to a certain amount of use. If I am not mistaken, more than 20 queries can be made per day.

- 1
- 2