php - setting a string for each entry in response -


i using following code extract certificate chain website. code works fine take certificates , bundles them 1 string $pem_encoded.

what set different string each certificate, how can this?

        $cont = @stream_context_get_params($result);         foreach($cont["options"]["ssl"]["peer_certificate_chain"] $cert) {             openssl_x509_export($cert, $pem_encoded);             print_r($pem_encoded);         }     } 

the output print_r($pem_encoded); this:

-----begin certificate----- kwybbquhawiwgqydvr0rbbiweiiod3d3lmdvb2dszs5jb20waayikwybbquhaqee xdbamcsgccsgaqufbzachh9odhrwoi8vcgtplmdvb2dszs5jb20vr0lbrziuy3j0 mcsgccsgaqufbzabhh9odhrwoi8vy2xpzw50czeuz29vz2xllmnvbs9vy3nwmb0g a1uddgqwbbsgaqj1vb+r5ia9zysggexxg+orfzambgnvhrmbaf8eajaamb8ga1ud /a6yfa2df67oyhzkxuogvwko+cfve91v+aaqvyltkzaczy/xaypi8wfj -----end certificate----- -----begin certificate----- vatogmkv7utzx8bhbyasxf6up7xbsdj0u/ck5vur6rxez/rtdfrk/j9u3n2+ogtv h8dqub8omana2ghzuwx//zo8pzcgjr1leqtrfste5vn8mxh7lnvg8y5kr0lsy+re ahqyzfpdfuulh8gzyr/nnag+yyuenwllhmgzxuyi+fovvuoashdgkuy6lyarxzmz easg8gf6lswmtlj14rbtcmou/m4iarnoz0ydl5cdfscx3nuvrtppuj5xt970jsxc vobhbw== -----end certificate----- -----begin certificate----- axmsr2vvvhj1c3qgr2xvymfsienbmiibijanbgkqhkig9w0baqefaaocaq8amiib cgkcaqea2swyyzd99bcjglz+w988bdjkcbd4kds8odhm+khdtgpptsehcijawc9m osm9bxilntjobbdqfngk5srgprdvgosjka+ejdbtg/otpphhmmlcgduuna2yrpiu t8rxh0pbfpvxlvdvis2aelet8u5fa9iajbku+bqvndnarqn7csirv8lvk83qlz6c jmtm386dgxhktubu1xupgc1v3sjs0l44u+vct4wt/lajnvxm5suopdkzalevajmr -----end certificate----- 

i programmatically seat each certificate separate string. each certificate begins -----begin certificate----- , ends -----end certificate----- in case there 3 certificates, 3 strings.

you can use this, catch separately every certificate.

<?php $str = '-----begin certificate----- kwybbquhawiwgqydvr0rbbiweiiod3d3lmdvb2dszs5jb20waayikwybbquhaqee xdbamcsgccsgaqufbzachh9odhrwoi8vcgtplmdvb2dszs5jb20vr0lbrziuy3j0 mcsgccsgaqufbzabhh9odhrwoi8vy2xpzw50czeuz29vz2xllmnvbs9vy3nwmb0g a1uddgqwbbsgaqj1vb+r5ia9zysggexxg+orfzambgnvhrmbaf8eajaamb8ga1ud /a6yfa2df67oyhzkxuogvwko+cfve91v+aaqvyltkzaczy/xaypi8wfj -----end certificate----- -----begin certificate----- vatogmkv7utzx8bhbyasxf6up7xbsdj0u/ck5vur6rxez/rtdfrk/j9u3n2+ogtv h8dqub8omana2ghzuwx//zo8pzcgjr1leqtrfste5vn8mxh7lnvg8y5kr0lsy+re ahqyzfpdfuulh8gzyr/nnag+yyuenwllhmgzxuyi+fovvuoashdgkuy6lyarxzmz easg8gf6lswmtlj14rbtcmou/m4iarnoz0ydl5cdfscx3nuvrtppuj5xt970jsxc vobhbw== -----end certificate----- -----begin certificate----- axmsr2vvvhj1c3qgr2xvymfsienbmiibijanbgkqhkig9w0baqefaaocaq8amiib cgkcaqea2swyyzd99bcjglz+w988bdjkcbd4kds8odhm+khdtgpptsehcijawc9m osm9bxilntjobbdqfngk5srgprdvgosjka+ejdbtg/otpphhmmlcgduuna2yrpiu t8rxh0pbfpvxlvdvis2aelet8u5fa9iajbku+bqvndnarqn7csirv8lvk83qlz6c jmtm386dgxhktubu1xupgc1v3sjs0l44u+vct4wt/lajnvxm5suopdkzalevajmr -----end certificate-----'; // certificates string preg_match_all('/-----begin certificate-----[^-]*-----end certificate-----/s', $str, $matches);  foreach ($matches[0] $match) {     echo $match;     // } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -