Skip to content

Commit e629ac2

Browse files
Potential fix for code scanning alert no. 93: Generic catch clause (#34)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent cffe38b commit e629ac2

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/AcmeService.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,13 @@ public async Task<CertificateModel> IssueCertificateAsync(
263263
pfxBytes = cert.ToPfx(privateKey).Build(domains[0], null);
264264
log?.Invoke("[CERT] PFX file built successfully");
265265
}
266-
catch (Exception ex)
266+
catch (CryptographicException ex)
267+
{
268+
log?.Invoke($"[CERT] ⚠️ PFX build failed ({ex.GetType().Name}: {ex.Message}). Falling back to leaf-only PFX export.");
269+
pfxBytes = BuildLeafOnlyPfx(leafCertificatePem, privateKeyPem);
270+
log?.Invoke("[CERT] Fallback PFX created (leaf certificate only)");
271+
}
272+
catch (InvalidOperationException ex)
267273
{
268274
log?.Invoke($"[CERT] ⚠️ PFX build failed ({ex.GetType().Name}: {ex.Message}). Falling back to leaf-only PFX export.");
269275
pfxBytes = BuildLeafOnlyPfx(leafCertificatePem, privateKeyPem);

0 commit comments

Comments
 (0)