Ajout export P12

This commit is contained in:
stef
2025-12-16 00:47:22 +01:00
parent 97ec520314
commit 04f08db87d
10 changed files with 226 additions and 86 deletions

View File

@@ -593,9 +593,12 @@ async fetchSubCAs() {
name: data.name,
common_name: data.common_name,
organization: data.organization,
organization_unit: data.organization_unit,
country: data.country,
province: data.province || '',
locality: data.locality || '',
street_address: data.street_address || '',
postal_code: data.postal_code || '',
email: data.email || '',
key_size: parseInt(data.key_size) || 4096,
valid_years: parseInt(data.valid_years) || 10,
@@ -632,6 +635,7 @@ async fetchSubCAs() {
name: data.name,
common_name: data.common_name,
organization: data.organization,
organization_unit: data.organization_unit,
email: data.email || '',
country: data.country,
province: data.province || '',
@@ -785,10 +789,16 @@ async fetchSubCAs() {
<h3>${ca.name}</h3>
<p><strong>Common Name:</strong> ${ca.common_name}</p>
<p><strong>Organization:</strong> ${ca.organization}</p>
<p><strong>Organizational Unit:</strong> ${ca.organization_unit}</p>
<p><strong>StreetAddress:</strong> ${ca.street_address}</p>
<p><strong>PostalCode:</strong> ${ca.postal_code}</p>
<p><strong>Valid From:</strong> ${new Date(ca.valid_from).toLocaleString()}</p>
<p><strong>Valid To:</strong> ${new Date(ca.valid_to).toLocaleString()}</p>
<p><strong>Serial:</strong> ${ca.serial_number}</p>
<button class="btn" onclick="window.open('${this.apiBase}/cas/${id}/download/cert')">Download Certificate</button>
<div class="button-group">
<button class="btn" onclick="window.open('${this.apiBase}/cas/${id}/download/cert')">Download Certificate</button>
<button class="btn" onclick="window.open('${this.apiBase}/cas/${id}/download/key')">Download Private Key</button>
</div>
`);
} catch (error) {
this.showError('Failed to load CA details');
@@ -804,7 +814,9 @@ async fetchSubCAs() {
this.showModal('Sub CA Details', `
<h3>${subca.name}</h3>
<p><strong>Common Name:</strong> ${subca.common_name}</p>
<p><strong>Subject:</strong> ${subca.subject}</p>
<p><strong>Organization:</strong> ${subca.organization}</p>
<p><strong>Organizational Unit:</strong> ${subca.organization_unit}</p>
<p><strong>Valid From:</strong> ${new Date(subca.valid_from).toLocaleString()}</p>
<p><strong>Valid To:</strong> ${new Date(subca.valid_to).toLocaleString()}</p>
<p><strong>Serial:</strong> ${subca.serial_number}</p>
@@ -818,12 +830,15 @@ async fetchSubCAs() {
async viewCertificate(id) {
try {
const response = await fetch(`${this.apiBase}/certificates/${id}`);
if (!response.ok) throw new Error('Not found');
const cert = await response.json();
this.showModal('Certificate Details', `
<h3>${cert.common_name}</h3>
<p><strong>Type:</strong> ${cert.type}</p>
<p><strong>SANs:</strong> ${cert.dns_names}
<p><strong>IP Address:</strong> ${cert.ip_adresses}
<p><strong>Valid From:</strong> ${new Date(cert.valid_from).toLocaleString()}</p>
<p><strong>Valid To:</strong> ${new Date(cert.valid_to).toLocaleString()}</p>
<p><strong>Status:</strong> ${cert.revoked ? 'Revoked' : new Date(cert.valid_to) > new Date() ? 'Valid' : 'Expired'}</p>
@@ -831,6 +846,7 @@ async fetchSubCAs() {
<div class="button-group">
<button class="btn" onclick="window.open('${this.apiBase}/certificates/${id}/download/cert')">Download Certificate</button>
<button class="btn" onclick="window.open('${this.apiBase}/certificates/${id}/download/key')">Download Private Key</button>
<button class="btn" onclick="window.open('${this.apiBase}/certificates/${id}/download/p12')">Download P12</button>
</div>
`);
} catch (error) {