Search code examples
phpapisslurltrusted

How can I check if a URLs SSL is valid? Any open APIs?


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?


Solution

  • 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.