I got this error messages a thousand times:
I added the root certification authority certificates and the intermediate certification authority certificates of all SSL certificates to the SharePoint root cert store:
In my case both certificates are saved as CER files in the same directory as the script file above.
To get the root and intermediate CA cert open the Internet Explorer and navigate to the SharePoint site.
Click the “Security Report” button:
Click “View certificates”
Select every certificate in the tree but not the last level: this last certificate is your SSL certificate itself. The top certificate is the “root certification authority certificate” and all certificates (1 or more) between the top node and the “last” certificate are the “intermediate certification authority certificates”. Select each of them and click “View Certificate”.
In the next dialog click “Details” and then click “Copy to file”
Maybe this is another solution for the problem.
First open the Farm Search Administration page (http(s)://<ca>:<port>/searchfarmdashboard.aspx).
Then change the setting “Ignore SSL warnings” to “yes”: