Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Can't get file from 'https' servers

Comments in 'Plugin Development' started by Survingo, May 17, 2016.

  1. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Hello community,

    last hour I realized that PocketMine is not able to get contents from websites with a 'https' certivicate.

    I tryed \file_get_contents($url) and it returned this error:
    Code:
     Unable to find the wrapper "https" 
    I made a other function to be sure that this really doesn't work.
    PHP:
        public function getcURL($url){
                       
    $curl curl_init($url);
                       
    curl_setopt($curlCURLOPT_RETURNTRANSFER1);
                       
    curl_setopt($curlCURLOPT_FOLLOWLOCATION1);
                       
    curl_setopt($curlCURLOPT_SSL_VERIFY_PEER0);
                       
    curl_setopt($curlCURLOPT_SSL_VERYIFY_HOST0);
                       
    $data curl_exec($curl);
                       
    curl_close($curl);
                       return 
    $data;
       }
    Then I got
    Code:
    Use of undefined constant CURLOPT_SSL_VERIFY_PEER
    So, is it really possible to add the https wrapper to PocketMine e.g. via \bin\php\php.ini or is it impossible?

    Thanks for reading, S-
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Have you tried accessing the url without secure connection?
    HotFireyDeath and Survingo like this.
  3. DC4CODE
    Offline

    DC4CODE Active Member

    Joined:
    Nov 19, 2015
    Posts:
    64
    Minecraft User:
    dxdsc9349
    Hmm.. That's pretty weird
  4. DC4CODE
    Offline

    DC4CODE Active Member

    Joined:
    Nov 19, 2015
    Posts:
    64
    Minecraft User:
    dxdsc9349
    The point is HTTPS Certificate Websites Don't work all together... And they should
  5. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    That works!


    But something with the encode is wrong. Still says I'm not connected to the Internet

    PHP:
                      $logger $this->getServer()->getLogger();
    $updateResult = print ($this->getcURL("http://raw.githubusercontent.com/Survingo/AutoUpdater/master/InternetTest.txt"));
                       
    $logger->info("§aChecking Internet Connection...");
                         if(
    $updateResult == "true"){
                           
    $logger->info("§aYou are connected to the Internet! Now checking for an Update...");
                           
    $this->checkForUpdate(); // Own very big and simple  function with yaml_parse and else
                             
    }else{
                               
    $logger->error("Can't check for an Update, because you are not connected to the Internet!");
                               }

    /* I removed from getcURL curl_setopt($curl, CURLOPT_SSL_VERIFY_PEER, 0);curl_setopt($curl, CURLOPT_SSL_VERYIFY_HOST, 0);*/
    Should I better use something like !== false because it should return false if someone is not connected?

    The weird thing is:
    It logs §aYou are connected to the Internet! Now checking for an Update... AND Can't check for an Update, because you are not connected to the Internet!
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    public function onEnable(){
    $this->getLogger()->info("Checking for updates...");
    $r = \pocketmine\utils\Utils::getUrl("http://raw.githubusercontent.com/Survingo/AutoUpdater/master/InternetTest.txt"5); // timeout: 5
            
    if($r){
                   
    # Check update, Idk what your file holds :P
            
    } else {
                    
    $this->getLogger()->info("Connection to update servers failed. Check your internet connection.");
            }
    }
    Survingo likes this.
  7. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Still doesn't work (lol).
    I tryed to run it directly onEnable() checkForUpdate() to test if I'm really not connected to the Internet/some errors, but it works...
    :|
  8. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Solved - higher timeout and
    PHP:
    if($r === \false){
    //Not connected
    }

Share This Page

Advertisement