<?php

// กำหนด path ให้เหมาะกับระบบของคุณ
$opensslCnf = '/etc/ssl/openssl.cnf';         // หรือ path ของ openssl.cnf ที่คุณใช้งานจริง
$crlPemPath = __DIR__ . '/crl.pem';
$crlDerPath = __DIR__ . '/public/data.crl';   // เก็บใน public/ เพื่อให้ดาวน์โหลดได้

// 1. สร้างไฟล์ CRL (PEM)
$cmd1 = "openssl ca -config " . escapeshellarg($opensslCnf) . " -gencrl -out " . escapeshellarg($crlPemPath);
exec($cmd1, $output1, $ret1);

if ($ret1 !== 0) {
    echo "❌ สร้าง crl.pem ไม่สำเร็จ:\n";
    echo implode("\n", $output1);
    exit(1);
}

echo "✅ สร้าง crl.pem สำเร็จ\n";

// 2. แปลง PEM → DER
$cmd2 = "openssl crl -in " . escapeshellarg($crlPemPath) . " -outform DER -out " . escapeshellarg($crlDerPath);
exec($cmd2, $output2, $ret2);

if ($ret2 !== 0) {
    echo "❌ แปลงเป็น DER ไม่สำเร็จ:\n";
    echo implode("\n", $output2);
    exit(1);
}

echo "✅ สร้าง data.crl (DER) สำเร็จ และเก็บไว้ที่ public/data.crl\n";

แท็ก: none

ปิดความเห็นแล้ว