Error using ssl cert with PHP

前端 未结 5 1218
后悔当初
后悔当初 2021-01-02 10:27

I am new to php and I am getting this error trying to load a cert

jameys-macbookpro41:~ user$ php -f ~/Sites/providerService.php

Warning: s

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-02 10:53

    You are getting an error because it's trying to find your cert.pem file in the directory you are running the script from, not the directory the script is in. In your example, it is your user directory "~".

    Try changing your class to this, or something similar:

    class pushNotifications {
    ...
         private $sslPem = 'cert.pem';
    ...
         function connectToAPNS(){
              $streamContext = stream_context_create();
              stream_context_set_option($streamContext, 'ssl', 'local_cert', dirname(__FILE__) . '/' . $this->sslPem);
    

提交回复
热议问题