takproto 0.4.2

Rust library for TAK (Team Awareness Kit) Protocol - send CoT messages to TAK servers with mTLS support
Documentation
//! Test trusted server cert with XML mode (no protocol negotiation)

use takproto::{TakClient, TlsConfigBuilder, CotEventBuilder};
use takproto::helpers::contact;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let args: Vec<String> = std::env::args().collect();
    if args.len() < 6 {
        eprintln!("Usage: {} <server:port> <server_name> <p12_file> <password> <server_cert.pem>", args[0]);
        std::process::exit(1);
    }

    let server_addr = &args[1];
    let server_name = &args[2];
    let p12_file = &args[3];
    let password = &args[4];
    let server_cert = &args[5];

    println!("Loading P12 and trusting server certificate...");
    let tls_config = TlsConfigBuilder::new()
        .with_p12(p12_file, password)?
        .with_additional_root_cert(server_cert)?
        .build()?;
    println!("✓ TLS configuration created\n");

    println!("Connecting to {}...", server_addr);
    let mut client = TakClient::connect_tls(server_addr, server_name, tls_config).await?;
    println!("✓ Connected!\n");

    println!("⚠️  Staying in XML mode - no protocol negotiation\n");

    println!("Sending test event (XML)...");
    let event = CotEventBuilder::new()
        .uid("TRUSTED-CERT-XML-TEST")
        .cot_type("a-f-G-U-C")
        .lat_lon(39.377445, -76.832160)
        .hae(10.0)
        .ce_le(9.9, 9.9)
        .how("m-g")
        .stale_minutes(5)
        .with_contact(contact("TrustedXML", None))
        .build()?;

    client.send_cot_event_xml(event).await?;
    println!("✓ Event sent!\n");

    println!("Check iTAK for 'TRUSTED-CERT-XML-TEST' marker.");
    println!("If this shows up, the TLS connection works properly.");
    println!("The issue is specific to protocol negotiation.");

    Ok(())
}