I'm distributing a Raspbian based RPi image, which contacts a webserver through PHP and file_get_contents() on startup. The image was created November 2019, the server certificate is newer, from June 2020.
On a newly flashed image, the connection fails:
PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in lib.php on line 83 PHP Warning: file_get_contents(): Failed to enable crypto in lib.php on line 83
If I run the request in a loop until it succeeds, it works after about 20 seconds. It then keeps working immediately on subsequent boots. To test this, the image was mounted on a different system and only the relevant file edited.
I suspected that CA certs or similar things get updated on startup, but I can not find any changed files related to that. (find / -mtime -1)
Apparently something is different after the first boot, yet nothing is different on the SD card.
Does anyone have any idea what could be causing this?