{"id":277,"date":"2011-09-14T12:28:44","date_gmt":"2011-09-14T04:28:44","guid":{"rendered":"http:\/\/www.genepeng.com\/?p=277"},"modified":"2011-09-14T12:31:21","modified_gmt":"2011-09-14T04:31:21","slug":"perl-ldap-start_tls-operations-error","status":"publish","type":"post","link":"https:\/\/www.genepeng.com\/index.php\/277","title":{"rendered":"perl ldap start_tls Operations error"},"content":{"rendered":"<p>When i use php script to call perl script which will query the ldap , the perl function start_tls\u00a0always return the error message &#8220;Operations error&#8221;, but it works well when call perl script directly with command line, it almost spent me a day to fix this problem, i finally found the root cause is that php process doesn&#8217;t have read permission to the cert\/key file<\/p>\n<p><span style=\"color: #ff6600;\">chmod a+r \/path\/to\/cert file<\/span><\/p>\n<p><span style=\"color: #ff6600;\">chmod a+r \/path\/to\/key file<\/span><\/p>\n<p>those two commands fixed the problem.<\/p>\n<p>following code demo how php call perl:<\/p>\n<blockquote>\n<pre>$pipespec = array\r\n    (\r\n    1 =&gt; array('pipe', 'w'), \/\/ client's stdout\r\n    2 =&gt; array('pipe', 'w'), \/\/ client's stderr\r\n);\r\n\r\n$pipes = array();\r\n$command = \"\/usr\/bin\/perl \/path\/to\/perl\/script.pl\";\r\n$process = proc_open($command, $pipespec, $pipes, $cwd, NULL);<\/pre>\n<p><!--more--><\/p>\n<pre>if (!is_resource($process))\r\n{\r\necho \"Failed : \" .  $command;<\/pre>\n<pre>}\r\n\r\n$stdout = stream_get_contents($pipes[1]);\r\n$stderr = stream_get_contents($pipes[2]);\r\nfclose($pipes[1]);\r\nfclose($pipes[2]);\r\necho \"&lt;br&gt;stdout: \" . $stdout;\r\necho \"&lt;br&gt;stderr: \" . $stderr;<\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>When i use php script to call perl script which will query the ldap , the perl function start_tls\u00a0always return the error message &#8220;Operations error&#8221;, but it works well when call perl script directly with command line, it almost spent me a day to fix this problem, i finally found the root cause is that &#8230; <a title=\"perl ldap start_tls Operations error\" class=\"read-more\" href=\"https:\/\/www.genepeng.com\/index.php\/277\" aria-label=\"More on perl ldap start_tls Operations error\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,3],"tags":[58,57],"_links":{"self":[{"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/posts\/277"}],"collection":[{"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/comments?post=277"}],"version-history":[{"count":3,"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/posts\/277\/revisions"}],"predecessor-version":[{"id":279,"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/posts\/277\/revisions\/279"}],"wp:attachment":[{"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/media?parent=277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/categories?post=277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/tags?post=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}