electron / electron/electron

[Feature Request]: Add an API to create a `Certificate` object from a `pem` file

Open
#34,726 0 comments 0 reactions 0 assignees View on GitHub
enhancement :sparkles:
Dominant language
C++
Stars
123k
Forks
17.5k
Avg merge
14h 22m
Merged PRs (30d)
873

Description

### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a feature request that matches the one I want to file, without success.

### Problem Description

Every use of `dialog.showCertificateTrustDialog` I've seen uses it to react to some event that passes `certificate` as an argument. There doesn't appear to be a way to create a [`Certificate`](https://www.electronjs.org/docs/latest/api/structures/certificate) from a file (without manually building the object I guess). I want to use `dialog.showCertificateTrustDialog` to trust certificates generated by [mitmproxy](https://github.com/mitmproxy/mitmproxy). What I have are `*.pem` files.

### Proposed Solution

I'm not sure where this belongs, certainly not in the `dialog` namespaces. Maybe `import { Certificate } from 'electron';` and have a static method on it like `Certificate.fromFile()`.

### Alternatives Considered

I assume it's possible to parse the file manually and re-create whatever shape electron expects the object to be. Or is `{data}` actually enough for `showCertificateTrustDialog` and all other fields are irrelevant? I don't have access to Windows or Mac right now to test it.

### Additional Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.