|
Some checks failed
Build / tag (push) Has been cancelled
Build / build (map[cross:false os:macos-latest target:x86_64-apple-darwin test:true]) (push) Has been cancelled
Build / build (map[cross:false os:ubuntu-latest target:x86_64-unknown-linux-gnu test:true]) (push) Has been cancelled
Build / build (map[cross:false os:ubuntu-latest target:x86_64-unknown-linux-musl test:true]) (push) Has been cancelled
Build / build (map[cross:false os:windows-latest target:x86_64-pc-windows-msvc test:true]) (push) Has been cancelled
Build / release (push) Has been cancelled
Build / upload (x86_64-apple-darwin) (push) Has been cancelled
Build / upload (x86_64-pc-windows-msvc) (push) Has been cancelled
Build / upload (x86_64-unknown-linux-gnu) (push) Has been cancelled
Build / upload (x86_64-unknown-linux-musl) (push) Has been cancelled
|
||
|---|---|---|
| .. | ||
| src | ||
| testfiles | ||
| Cargo.toml | ||
| README.md | ||
jsonwebkey-convert
Convert an RSA public key between Json Web Key and DER/PEM format.
Convert PEM to JWK
use jsonwebkey_convert::*;
use jsonwebkey_convert::der::FromPem;
fn main() -> Result<(), Error> {
let pem_data = include_str!("../testfiles/test1.pem");
let rsa_jwk = RSAPublicKey::from_pem(pem_data)?;
let jwk_byte_vec = serde_json::to_string(&rsa_jwk);
Ok(())
}
Convert JWK to PEM
use jsonwebkey_convert::*;
use jsonwebkey_convert::der::ToPem;
fn main() -> Result<(), Error> {
let jwk_data = include_str!("../testfiles/test1.json");
let rsa_jwk: RSAPublicKey = jwk_data.parse()?;
let pem_data = rsa_jwk.to_pem()?;
Ok(())
}