2016-05-04 27 views
2

嗨,對不起我的英文不好。帶密碼的SSL證書肥皂服務(PHP)

我需要訪問具有受密碼保護的證書的SOAP服務。我是新的PHP(在codeigniter 2中的PHP 5.4),並嘗試了一些不適合我的選項。

我有常量訪問:

const WSDL = 'https://sedeapl.dgt.gob.es:8080/WS_IEST_COMP/descargaArchivoMicrodatosService?wsdl'; 

const XMLNS = 'https://sedeapl.dgt.gob.es:8080/WS_IEST_COMP/descargaArchivoMicrodatosService'; 

const LOCAL_CERT_PASSWD = 'HERE I HAVE THE PASS OF THE CERT'; 
const LOCAL_CERT = './certificados/Certificados.p12'; 

private $client; 

我已經試過這個選項:

選項A:

$this->client = new SoapClient(self::WSDL, array(
       "trace"   => 1, 
       "exceptions" => true, 
       "local_cert" => self::LOCAL_CERT, 
       "uri"   => "urn:xmethods-delayed-quotes", 
       "style"   => SOAP_RPC, 
       "use"   => SOAP_ENCODED, 
       "soap_version" => SOAP_1_2 , 
       "location"  => self::XMLNS 
      ) 
     ); 

選項B:

$this->$client = new SoapClient(self::WSDL, array('local_cert' => self::LOCAL_CERT)); 

我有不知道如何添加passw ORD。這些解決方案是我在這裏找到的stackoverflow。在兩個我都有同樣的錯誤:

SoapClient :: SoapClient():無法找到包裝「https」 - 你忘了配置PHP時啓用它?

我已經uncomented在php.ini

我有證書的那些路由嘗試了 「延長= php_openssl.dll」:

const LOCAL_CERT = 'certificados/Certificados.p12'; 
const LOCAL_CERT = 'Certificados.p12'; 
const LOCAL_CERT = './certificados/Certificados.p12'; 

任何有關於我能做些什麼的想法。非常感謝你!

+0

什麼操作系統你使用? –

回答

1

首先你需要轉換的.p12爲.pem在Linux中
你可以用下面的命令做的
openssl pkcs12 -in Certificados.p12 -out Certificados.pem -clcerts

然後嘗試以下方法:

$options = array(); 

$options['trace'] = true; 
$options['exceptions'] = true; 
$options['local_cert'] = 'path to your .pem file'; 
$options['passphrase'] = self::LOCAL_CERT_PASSWD; 

try { 
    $soapClient = new SoapClient(self::WSDL, $options); 

    echo '<pre>';   
    // wsdl methods 
    print_r($soapClient->__getFunctions());   
    echo '</pre>'; 
} 
catch (Exception $e) 
{ 
    echo $e->getMessage(), '<br />', $e->getTraceAsString(); 
} 
+0

現在我有Certificados.pem在: Proyect 源文件 應用 certificados Certificados.pem 控制器 控制器的代碼訪問服務 是正確的這條道路? $ options ['local_cert'] ='./certificados/Certificados.pem'; 我仍然有錯誤: 消息:SoapClient :: SoapClient():無法找到包裝「https」 - 你忘記配置PHP時啓用它? 消息:SoapClient :: SoapClient():I/O警告:未能加載外部實體「https://sedeapl.dgt.gob.es:8080/WS_IEST_COMP/descargaArchivoMicrodatosService?wsdl」 – Noark

+0

哇這個評論並不節省格式。 – Noark

+0

@Noark是否在啓用php_openssl後重新啓動了您的Web服務器?也嘗試file_get_contents(self :: WSDL); –