Rumah > Soal Jawab > teks badan
P粉3511384622023-09-06 10:11:11
Terima kasih kepada @neubert kerana memberikan jawapan yang saya perlukan dan saya ingin berkongsi ini dengan sesiapa sahaja yang mempunyai soalan yang sama seperti saya.
<?php require __DIR__ . '/vendor/autoload.php'; use phpseclib3\File\X509; ?> <!DOCTYPE html> <html> <head> <title>CSR Decode</title> <style type="text/css"> body{ background-color: #f1f1f1; font-family: Arial, sans-serif; color: #333333; } table.section{width:100%;} table.ftable td{padding:0px;text-align:center;font-size:13px;} h3{ color: #2e6da4; padding: 10px; font-size: 20px; text-align: center; margin-top: 0px; margin-bottom: 15px; border-radius: 10px; } table{ width: 50%; margin: auto; border-collapse: collapse; border: 1px solid #d4d4d4; text-align: left; } th, td{ padding: 8px; border: 1px solid #d4d4d4; font-size:15px; } tr:nth-child(even){ background-color: #f2f2f2; } img{ width: 50%; margin: auto; margin-bottom: 10px; } table.table td{border:none;} table.table{border:none;} input[type="text"] {width: 30%;padding: 5px 20px;border:1px solid white;} input[type="submit"]{ width: 16%; padding: 5px 20px; background-color:#67BC5A; color:white; font-weight:bold; border:1px solid #67BC5A; border-radius:5px;} form.form {padding-bottom: 20px;} p { display: flex; justify-content: center; font-weight: bold; font-size: 24px; } .csr_info { display: flex; justify-content: center; } .csr_info > ul{ list-style: none; } .csr_info > ul > li{ background: url(./img/check.png) no-repeat left; font-size: 14px; height: 24px; padding: 20px 0 0px 58px; margin: auto; font-weight: normal; line-height: 4px; } </style> </head> <body> <table class="ftable" style="border:none;"> <tr> <td style="border:none;"> <h3>Decode CSR</h3> <form class="form"action="" method="POST"> <div> <textarea name="csr" rows="22" cols="99"></textarea> </div> <div> <input type="submit" name="submit" value="Decode CSR"> </div> </form> </tr> </td> </table> <?php if(isset($_POST['submit'])){ $csr = $_POST['csr']; $x509 = new X509(); $csr2 = $x509->loadCSR($csr); ?> <p>CSR Information</p> <div class="csr_info"> <ul> <li> <strong>Common Name</strong>: <?php $result = array_values($x509->getDNProp('CN')); echo $result[0]; ?> </li> <li> <strong>Subject Alternative Name:</strong>: <?php $ext = array_values($x509->getExtension('id-ce-subjectAltName')); foreach ($ext as $value) { $san = array_values($value); echo " , " .$san[0]; } ?> </li> <li> <strong>Organization</strong>: <?php $result = array_values($x509->getDNProp('O')); echo $result[0]; ?> </li> <li> <strong>Organization Unit</strong>: <?php $result = array_values($x509->getDNProp('OU')); echo $result[0]; ?> </li> <li> <strong>Locality</strong>: <?php $result = array_values($x509->getDNProp('L')); echo $result[0]; ?> </li> <li> <strong>State</strong>: <?php $result = array_values($x509->getDNProp('ST')); echo $result[0]; ?> </li> <li> <strong>Country</strong>: <?php $result = array_values($x509->getDNProp('C')); echo $result[0]; ?> </li> </ul> <?php } ?> </div> </body> </html>