X.509 certificate to OpenPGP certificate

Original link: https://www.liesauer.net/blog/post/pem2openpgp.html

I recently applied for a personal code signing certificate, and I was thinking about whether I could use it to sign Git Commit. After a little searching, there is a way to convert it.

##pem2openpgp

`pem2openpgp` is a software under linux for converting RSA private keys in PEM format to OpenPGP format. However, the DSA algorithm is not supported, and the private key with password protection is not supported.

## monkeysphere

`pem2openpgp` is a software under the `monkeysphere` package, so you must first install `monkeysphere` to use it.

“`shell

sudo apt-get install monkeysphere

“`

## Certificate conversion

###PEM2OPENPGP_USAGE_FLAGS

This environment variable corresponds to the role of the OpenPGP certificate, and uses `,` to separate multiple purposes.

1. `certify`: certify other subkeys

2. `sign`: sign

3. `encrypt`: encryption

4. `authenticate`: authentication

###UID

UID can be considered as the identification code of the key, which is used for people to better identify the key. It generally consists of three parts: `name (remarks)`, such as `Zhang San`.

We use the following command to convert the private key of the X.509 certificate in pem format to OpenPGP format and import it into the library.

“`shell

PEM2OPENPGP_USAGE_FLAGS=certify,sign,encrypt pem2openpgp [uid] pub.asc

gpg -a –export-secret-key [pubkey] > pri.asc

“`

So far, the conversion of the X.509 certificate to the OpenPGP certificate has been completed. If you want to read the related articles about Git Commit signature, please see “[Signing Git Commit with GPG under Windows](https://ift.tt/L4BuJD9 post/sign-git-commit-with-gpg-under-windows.html)”.

This article is reproduced from: https://www.liesauer.net/blog/post/pem2openpgp.html
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment