Ejemplo n.º 1
0
 /**
  * send http post request
  *
  * @param string $url
  * @param array $fields data send by the request
  * @return bool
  */
 public function post($url, array $fields)
 {
     $fieldsString = $this->assemblePostParameters($fields);
     $certBundle = $this->certificateManager->getCertificateBundle();
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, count($fields));
     curl_setopt($ch, CURLOPT_POSTFIELDS, (string) $fieldsString);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
     if (is_readable($certBundle)) {
         curl_setopt($ch, CURLOPT_CAINFO, $certBundle);
     }
     $result = curl_exec($ch);
     $success = $result ? true : false;
     curl_close($ch);
     return array('success' => $success, 'result' => $result);
 }
Ejemplo n.º 2
0
 /**
  * Get the full local path to the certificate bundle for this user
  *
  * @param string $uid (optional) user to get the certificate bundle for, use `null` to get the system bundle
  * @return string
  */
 public function getAbsoluteBundlePath($uid = '')
 {
     if ($uid === '') {
         $uid = $this->uid;
     }
     if ($this->needsRebundling($uid)) {
         if (is_null($uid)) {
             $manager = new CertificateManager(null, $this->view, $this->config);
             $manager->createCertificateBundle();
         } else {
             $this->createCertificateBundle();
         }
     }
     return $this->view->getLocalFile($this->getCertificateBundle($uid));
 }
Ejemplo n.º 3
0
 function testGetCertificateBundle()
 {
     $this->assertSame('/' . $this->username . '/files_external/rootcerts.crt', $this->certificateManager->getCertificateBundle());
 }