File: dane-generate.rs

package info (click to toggle)
rust-sequoia-net 0.30.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 304 kB
  • sloc: makefile: 6
file content (28 lines) | stat: -rw-r--r-- 638 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! Demonstrates how to generate DANE records.

use std::env;

use sequoia_openpgp::{
    Cert,
    Result,
    parse::Parse,
    policy::StandardPolicy,
};

use sequoia_net::dane;

fn main() -> Result<()> {
    let domain = env::args()
        .nth(1).expect("Usage: dane-get <DOMAIN> <CERT-FILE>");
    let cert_file = env::args()
        .nth(2).expect("Usage: dane-get <DOMAIN> <CERT-FILE>");

    let p = StandardPolicy::new();
    let cert = Cert::from_file(cert_file)?;
    let vcert = cert.with_policy(&p, None)?;
    for record in dane::generate(&vcert, domain, None, None)? {
        println!("{}", record);
    }

    Ok(())
}