php里面有内置的验证证书的功能
//如果弄反了 $temp_key = $private_key; $temp_certificate = openssl_x509_read($server_certificate); if (!$temp_certificate){ $temp_certificate = openssl_x509_read($private_key ); $temp_key = $server_certificate; $server_certificate = $private_key; } if (!$temp_certificate) { return $this->returnArr(1003,'证书有问题'); } if (!openssl_get_privatekey($temp_key) ) { return $this->returnArr(1004,'私钥有问题'); } if (!openssl_x509_check_private_key($server_certificate,$temp_key)) { return $this->returnArr(1005,'证书和私钥不匹配'); } $private_key = $temp_key; //解析证书内容 $ret = openssl_x509_parse($temp_certificate);