openvpn-mgmt-codec 0.8.0

OpenVPN management protocol codecs (tokio-util en/decoder implementations).
Documentation
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
use std::collections::BTreeMap;
use std::fmt;

use crate::auth::AuthType;
use crate::client_event::ClientEvent;
use crate::log_level::LogLevel;
use crate::openvpn_state::OpenVpnState;
use crate::redacted::Redacted;

/// Sub-types of `>PASSWORD:` notifications. The password notification
/// has several distinct forms with completely different structures.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PasswordNotification {
    /// `>PASSWORD:Need 'Auth' username/password`
    NeedAuth {
        /// The credential set being requested.
        auth_type: AuthType,
    },

    /// `>PASSWORD:Need 'Private Key' password`
    NeedPassword {
        /// The credential set being requested.
        auth_type: AuthType,
    },

    /// `>PASSWORD:Verification Failed: 'Auth'`
    VerificationFailed {
        /// The credential set that failed verification.
        auth_type: AuthType,
    },

    /// Static challenge: `>PASSWORD:Need 'Auth' username/password SC:{flag},{challenge}`
    /// The flag is a multi-bit integer: bit 0 = ECHO, bit 1 = FORMAT.
    StaticChallenge {
        /// Whether to echo the user's response (bit 0 of the SC flag).
        echo: bool,
        /// Whether the response should be concatenated with the password
        /// as plain text (bit 1 of the SC flag). When `false`, the response
        /// and password are base64-encoded per the SCRV1 format.
        response_concat: bool,
        /// The challenge text presented to the user.
        challenge: String,
    },

    /// `>PASSWORD:Auth-Token:{token}`
    ///
    /// Pushed by the server when `--auth-token` is active. The client should
    /// store this token and use it in place of the original password on
    /// subsequent re-authentications.
    ///
    /// Source: OpenVPN `manage.c` — `management_auth_token()`.
    AuthToken {
        /// The opaque auth-token string (redacted in debug output).
        token: Redacted,
    },

    /// Dynamic challenge (CRV1):
    /// `>PASSWORD:Verification Failed: 'Auth' ['CRV1:{flags}:{state_id}:{username_b64}:{challenge}']`
    DynamicChallenge {
        /// Comma-separated CRV1 flags.
        flags: String,
        /// Opaque state identifier for the auth backend.
        state_id: String,
        /// Base64-encoded username. Note: visible in [`Debug`] output — callers
        /// handling PII should avoid logging this variant without filtering.
        username_b64: String,
        /// The challenge text presented to the user.
        challenge: String,
    },
}

/// ENV key names whose values are masked in `Debug` output to prevent
/// accidental exposure in logs. Used by `RedactedEnv` below (invoked from
/// `derive_more::Debug` on [`Notification::Client::env`]).
#[allow(dead_code)] // used via derive_more::Debug attribute
const SENSITIVE_ENV_KEYS: &[&str] = &["password"];

/// A parsed real-time notification from OpenVPN.
///
/// The [`Debug`] implementation masks the values of known sensitive ENV
/// keys (e.g. `password`) in [`Client`](Notification::Client) notifications,
/// printing `<redacted>` instead.
#[derive(derive_more::Debug, Clone, PartialEq, Eq)]
pub enum Notification {
    /// A multi-line `>CLIENT:` notification (CONNECT, REAUTH, ESTABLISHED,
    /// DISCONNECT). The header and all ENV key=value pairs are accumulated
    /// into a single struct before this is emitted.
    Client {
        /// The client event sub-type.
        event: ClientEvent,
        /// Client ID (sequential, assigned by OpenVPN).
        cid: u64,
        /// Key ID (present for CONNECT/REAUTH, absent for ESTABLISHED/DISCONNECT).
        kid: Option<u64>,
        /// Accumulated ENV map. Each `>CLIENT:ENV,key=val` line becomes one
        /// entry. The terminating `>CLIENT:ENV,END` is consumed but not
        /// included. If a key appears more than once, the last value wins.
        #[debug("{:?}", RedactedEnv(env))]
        env: BTreeMap<String, String>,
    },

    /// A single-line `>CLIENT:ADDRESS` notification.
    ClientAddress {
        /// Client ID.
        cid: u64,
        /// Assigned virtual address.
        addr: String,
        /// Whether this is the primary address for the client.
        primary: bool,
    },

    /// `>STATE:timestamp,name,desc,local_ip,remote_ip,remote_port,local_addr,local_port,local_ipv6`
    ///
    /// Field order per management-notes.txt: (a) timestamp, (b) state name,
    /// (c) description, (d) TUN/TAP local IPv4, (e) remote server address,
    /// (f) remote server port, (g) local address, (h) local port,
    /// (i) TUN/TAP local IPv6.
    State {
        /// (a) Unix timestamp of the state change.
        timestamp: u64,
        /// (b) State name (e.g. `Connected`, `Reconnecting`).
        name: OpenVpnState,
        /// (c) Verbose description (mostly for RECONNECTING/EXITING).
        description: String,
        /// (d) TUN/TAP local IPv4 address (may be empty).
        local_ip: String,
        /// (e) Remote server address (may be empty).
        remote_ip: String,
        /// (f) Remote server port (empty in many states).
        remote_port: Option<u16>,
        /// (g) Local address (may be empty).
        local_addr: String,
        /// (h) Local port (empty in many states).
        local_port: Option<u16>,
        /// (i) TUN/TAP local IPv6 address (may be empty).
        local_ipv6: String,
    },

    /// `>BYTECOUNT:bytes_in,bytes_out` (client mode)
    ByteCount {
        /// Bytes received since last reset.
        bytes_in: u64,
        /// Bytes sent since last reset.
        bytes_out: u64,
    },

    /// `>BYTECOUNT_CLI:cid,bytes_in,bytes_out` (server mode, per-client)
    ByteCountCli {
        /// Client ID.
        cid: u64,
        /// Bytes received from this client.
        bytes_in: u64,
        /// Bytes sent to this client.
        bytes_out: u64,
    },

    /// `>LOG:timestamp,level,message`
    Log {
        /// Unix timestamp of the log entry.
        timestamp: u64,
        /// Log severity level.
        level: LogLevel,
        /// The log message text.
        message: String,
    },

    /// `>ECHO:timestamp,param_string`
    Echo {
        /// Unix timestamp.
        timestamp: u64,
        /// The echoed parameter string.
        param: String,
    },

    /// `>HOLD:Waiting for hold release[:N]`
    Hold {
        /// The hold message text.
        text: String,
    },

    /// `>FATAL:message`
    Fatal {
        /// The fatal error message.
        message: String,
    },

    /// `>PKCS11ID-COUNT:count`
    Pkcs11IdCount {
        /// Number of available PKCS#11 identities.
        count: u32,
    },

    /// `>NEED-OK:Need 'name' confirmation MSG:message`
    NeedOk {
        /// The prompt name.
        name: String,
        /// The prompt message to display.
        message: String,
    },

    /// `>NEED-STR:Need 'name' input MSG:message`
    NeedStr {
        /// The prompt name.
        name: String,
        /// The prompt message to display.
        message: String,
    },

    /// `>RSA_SIGN:base64_data`
    RsaSign {
        /// Base64-encoded data to be signed.
        data: String,
    },

    /// `>PK_SIGN:base64_data[,algorithm]`
    ///
    /// Sent by OpenVPN 2.5+ when `--management-external-key` is active and
    /// a signature is needed. The management client responds with
    /// [`PkSig`](crate::OvpnCommand::PkSig).
    ///
    /// The `algorithm` field is present only when the management client
    /// announced version > 2 via the `version` command. For RSA-PSS, the
    /// algorithm includes comma-separated params:
    /// `RSA_PKCS1_PSS_PADDING,hashalg=SHA256,saltlen=max`.
    ///
    /// Source: [`management-notes.txt`](https://github.com/OpenVPN/openvpn/blob/master/doc/management-notes.txt),
    /// [`ssl_openssl.c` `get_sig_from_man()`](https://github.com/OpenVPN/openvpn/blob/master/src/openvpn/ssl_openssl.c).
    PkSign {
        /// Base64-encoded data to be signed.
        data: String,
        /// Signing algorithm (e.g. `RSA_PKCS1_PADDING`, `ECDSA`,
        /// `RSA_PKCS1_PSS_PADDING,hashalg=SHA256,saltlen=max`).
        /// Only present when management client version > 2.
        algorithm: Option<String>,
    },

    /// `>INFOMSG:extra`
    ///
    /// Authentication-related information from the server, such as
    /// `CR_TEXT` challenges, `OPEN_URL`, or `WEB_AUTH` SSO directives.
    /// Delivered to the client via `client-pending-auth`.
    ///
    /// Source: [`management-notes.txt`](https://github.com/OpenVPN/openvpn/blob/master/doc/management-notes.txt)
    /// (see "client-pending-auth" section).
    InfoMsg {
        /// The info message content (e.g. `WEB_AUTH::https://...` or
        /// `CR_TEXT:R,E:Enter your TOTP code`).
        extra: String,
    },

    /// `>NEED-CERTIFICATE:hint`
    ///
    /// Requests an external certificate when `--management-external-cert`
    /// is active. The hint identifies which certificate to provide
    /// (e.g. `macosx-keychain:subject:o=OpenVPN-TEST`). The management
    /// client responds with [`Certificate`](crate::OvpnCommand::Certificate).
    NeedCertificate {
        /// Hint string for locating the certificate.
        hint: String,
    },

    /// `>INFO:message`
    ///
    /// Informational notification sent at any time (not just the initial banner).
    /// Notable sub-types include `>INFO:WEB_AUTH::url` for web-based authentication.
    ///
    /// The initial `>INFO:` banner on connect is still surfaced as
    /// [`OvpnMessage::Info`] (before the codec enters notification mode).
    /// This variant captures all subsequent `>INFO:` messages.
    Info {
        /// The info message content.
        message: String,
    },

    /// `>REMOTE:host,port,protocol`
    Remote {
        /// Remote server hostname or IP.
        host: String,
        /// Remote server port.
        port: u16,
        /// Transport protocol.
        protocol: crate::transport_protocol::TransportProtocol,
    },

    /// `>PROXY:index,proxy_type,host`
    ///
    /// Sent when OpenVPN needs proxy information (requires
    /// `--management-query-proxy`). The management client responds
    /// with a `proxy` command.
    Proxy {
        /// Connection index (1-based).
        index: u32,
        /// Proxy type (e.g. `TCP`, `UDP`).
        proxy_type: crate::transport_protocol::TransportProtocol,
        /// Server hostname or IP to connect through.
        host: String,
    },

    /// `>PASSWORD:...` — see [`PasswordNotification`] for the sub-types.
    Password(PasswordNotification),

    /// Fallback for any notification type not explicitly modeled above.
    /// Kept for forward compatibility with future OpenVPN versions.
    Simple {
        /// The notification type keyword (e.g. `"BYTECOUNT"`).
        kind: String,
        /// Everything after the first colon.
        payload: String,
    },
}

/// Helper for Debug output: displays env entries, masking sensitive keys.
/// Constructed by `derive_more::Debug` on [`Notification::Client::env`].
#[allow(dead_code)] // used via derive_more::Debug attribute
struct RedactedEnv<'a>(&'a BTreeMap<String, String>);

impl fmt::Debug for RedactedEnv<'_> {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.debug_map()
            .entries(self.0.iter().map(|(k, v)| {
                if SENSITIVE_ENV_KEYS.contains(&k.as_str()) {
                    (k.as_str(), "<redacted>")
                } else {
                    (k.as_str(), v.as_str())
                }
            }))
            .finish()
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::transport_protocol::TransportProtocol;
    // --- Debug redaction ---

    #[test]
    fn debug_redacts_password_env_key() {
        let notification = Notification::Client {
            event: ClientEvent::Connect,
            cid: 1,
            kid: Some(0),
            env: BTreeMap::from([
                ("common_name".to_string(), "alice".to_string()),
                ("password".to_string(), "s3cret".to_string()),
            ]),
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("alice"), "non-sensitive values should appear");
        assert!(
            !dbg.contains("s3cret"),
            "password value must not appear in Debug output"
        );
        assert!(
            dbg.contains("<redacted>"),
            "password value should be replaced with <redacted>"
        );
    }

    #[test]
    fn debug_does_not_redact_non_sensitive_keys() {
        let notification = Notification::Client {
            event: ClientEvent::Disconnect,
            cid: 5,
            kid: None,
            env: BTreeMap::from([("untrusted_ip".to_string(), "10.0.0.1".to_string())]),
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("10.0.0.1"));
    }

    // --- PasswordNotification variants ---

    #[test]
    fn password_notification_debug_redacts_token() {
        let notification = PasswordNotification::AuthToken {
            token: Redacted::new("super-secret-token".to_string()),
        };
        let dbg = format!("{notification:?}");
        assert!(
            !dbg.contains("super-secret-token"),
            "auth token must not appear in Debug output"
        );
    }

    #[test]
    fn password_notification_eq() {
        let need_auth = PasswordNotification::NeedAuth {
            auth_type: AuthType::Auth,
        };
        let need_auth_same = PasswordNotification::NeedAuth {
            auth_type: AuthType::Auth,
        };
        assert_eq!(need_auth, need_auth_same);

        let need_password = PasswordNotification::NeedPassword {
            auth_type: AuthType::PrivateKey,
        };
        assert_ne!(need_auth, need_password);
    }

    #[test]
    fn password_notification_static_challenge_fields() {
        let static_challenge = PasswordNotification::StaticChallenge {
            echo: true,
            response_concat: false,
            challenge: "Enter PIN".to_string(),
        };
        if let PasswordNotification::StaticChallenge {
            echo,
            response_concat,
            challenge,
        } = static_challenge
        {
            assert!(echo);
            assert!(!response_concat);
            assert_eq!(challenge, "Enter PIN");
        } else {
            panic!("wrong variant");
        }
    }

    #[test]
    fn password_notification_dynamic_challenge_fields() {
        let dynamic_challenge = PasswordNotification::DynamicChallenge {
            flags: "R,E".to_string(),
            state_id: "abc123".to_string(),
            username_b64: "dXNlcg==".to_string(),
            challenge: "Enter OTP".to_string(),
        };
        if let PasswordNotification::DynamicChallenge {
            flags,
            state_id,
            challenge,
            ..
        } = dynamic_challenge
        {
            assert_eq!(flags, "R,E");
            assert_eq!(state_id, "abc123");
            assert_eq!(challenge, "Enter OTP");
        } else {
            panic!("wrong variant");
        }
    }

    // --- Notification Debug output for each variant ---

    #[test]
    fn debug_state_notification() {
        let notification = Notification::State {
            timestamp: 1700000000,
            name: OpenVpnState::Connected,
            description: "SUCCESS".to_string(),
            local_ip: "10.0.0.2".to_string(),
            remote_ip: "1.2.3.4".to_string(),
            remote_port: Some(1194),
            local_addr: "192.168.1.5".to_string(),
            local_port: Some(51234),
            local_ipv6: String::new(),
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("State"));
        assert!(dbg.contains("Connected"));
        assert!(dbg.contains("10.0.0.2"));
    }

    #[test]
    fn debug_bytecount() {
        let notification = Notification::ByteCount {
            bytes_in: 1024,
            bytes_out: 2048,
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("1024"));
        assert!(dbg.contains("2048"));
    }

    #[test]
    fn debug_bytecount_cli() {
        let notification = Notification::ByteCountCli {
            cid: 7,
            bytes_in: 100,
            bytes_out: 200,
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("ByteCountCli"));
        assert!(dbg.contains("7"));
    }

    #[test]
    fn debug_log() {
        let notification = Notification::Log {
            timestamp: 1700000000,
            level: LogLevel::Warning,
            message: "something happened".to_string(),
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("Log"));
        assert!(dbg.contains("something happened"));
    }

    #[test]
    fn debug_echo() {
        let notification = Notification::Echo {
            timestamp: 123,
            param: "push-update".to_string(),
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("Echo"));
        assert!(dbg.contains("push-update"));
    }

    #[test]
    fn debug_hold() {
        let notification = Notification::Hold {
            text: "Waiting for hold release".to_string(),
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("Hold"));
    }

    #[test]
    fn debug_fatal() {
        let notification = Notification::Fatal {
            message: "cannot allocate TUN/TAP".to_string(),
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("Fatal"));
        assert!(dbg.contains("cannot allocate TUN/TAP"));
    }

    #[test]
    fn debug_remote() {
        let notification = Notification::Remote {
            host: "vpn.example.com".to_string(),
            port: 1194,
            protocol: TransportProtocol::Udp,
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("Remote"));
        assert!(dbg.contains("vpn.example.com"));
    }

    #[test]
    fn debug_proxy() {
        let notification = Notification::Proxy {
            index: 1,
            proxy_type: TransportProtocol::Tcp,
            host: "proxy.local".to_string(),
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("Proxy"));
        assert!(dbg.contains("proxy.local"));
    }

    #[test]
    fn debug_pk_sign_with_algorithm() {
        let notification = Notification::PkSign {
            data: "dGVzdA==".to_string(),
            algorithm: Some("RSA_PKCS1_PADDING".to_string()),
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("PkSign"));
        assert!(dbg.contains("RSA_PKCS1_PADDING"));
        assert!(dbg.contains("dGVzdA=="));
    }

    #[test]
    fn debug_pk_sign_without_algorithm() {
        let notification = Notification::PkSign {
            data: "dGVzdA==".to_string(),
            algorithm: None,
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("PkSign"));
        assert!(dbg.contains("None"));
    }

    #[test]
    fn debug_info_notification() {
        let notification = Notification::Info {
            message: "WEB_AUTH::https://example.com/auth".to_string(),
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("Info"));
        assert!(dbg.contains("WEB_AUTH"));
    }

    #[test]
    fn debug_simple_fallback() {
        let notification = Notification::Simple {
            kind: "FUTURE_TYPE".to_string(),
            payload: "some data".to_string(),
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("FUTURE_TYPE"));
        assert!(dbg.contains("some data"));
    }

    #[test]
    fn debug_client_address() {
        let notification = Notification::ClientAddress {
            cid: 42,
            addr: "10.8.0.6".to_string(),
            primary: true,
        };
        let dbg = format!("{notification:?}");
        assert!(dbg.contains("ClientAddress"));
        assert!(dbg.contains("10.8.0.6"));
        assert!(dbg.contains("true"));
    }

    // --- OvpnMessage variants ---

    #[test]
    fn ovpn_message_eq() {
        assert_eq!(
            OvpnMessage::Success("pid=42".to_string()),
            OvpnMessage::Success("pid=42".to_string()),
        );
        assert_ne!(
            OvpnMessage::Success("a".to_string()),
            OvpnMessage::Error("a".to_string()),
        );
    }

    #[test]
    fn ovpn_message_pkcs11_entry() {
        let msg = OvpnMessage::Pkcs11IdEntry {
            index: "0".to_string(),
            id: "slot_0".to_string(),
            blob: "AQID".to_string(),
        };
        let dbg = format!("{msg:?}");
        assert!(dbg.contains("Pkcs11IdEntry"));
        assert!(dbg.contains("slot_0"));
    }

    #[test]
    fn ovpn_message_password_prompt() {
        assert_eq!(OvpnMessage::PasswordPrompt, OvpnMessage::PasswordPrompt);
    }

    #[test]
    fn ovpn_message_unrecognized() {
        let msg = OvpnMessage::Unrecognized {
            line: "garbage".to_string(),
            kind: crate::unrecognized::UnrecognizedKind::UnexpectedLine,
        };
        let dbg = format!("{msg:?}");
        assert!(dbg.contains("garbage"));
    }
}

/// A fully decoded message from the OpenVPN management interface.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OvpnMessage {
    /// A success response: `SUCCESS: [text]`.
    Success(String),

    /// An error response: `ERROR: [text]`.
    Error(String),

    /// A multi-line response block (from `status`, `version`, `help`, etc.).
    /// The terminating `END` line is consumed but not included.
    MultiLine(Vec<String>),

    /// Parsed response from `>PKCS11ID-ENTRY:` notification (sent by
    /// `pkcs11-id-get`). Wire: `>PKCS11ID-ENTRY:'index', ID:'id', BLOB:'blob'`
    Pkcs11IdEntry {
        /// Certificate index.
        index: String,
        /// PKCS#11 identifier.
        id: String,
        /// Base64-encoded certificate blob.
        blob: String,
    },

    /// A real-time notification, either single-line or accumulated multi-line.
    Notification(Notification),

    /// The `>INFO:` banner sent when the management socket first connects.
    /// Technically a notification, but surfaced separately since it's always
    /// the first thing you see and is useful for version detection.
    Info(String),

    /// Management interface password prompt. Sent when `--management` is
    /// configured with a password file. The client must respond with the
    /// password (via [`crate::OvpnCommand::ManagementPassword`]) before any
    /// commands are accepted.
    PasswordPrompt,

    /// A line that could not be classified into any known message type.
    /// Contains the raw line and a description of what went wrong.
    Unrecognized {
        /// The raw line that could not be parsed.
        line: String,
        /// Why the line was not recognized.
        kind: crate::unrecognized::UnrecognizedKind,
    },
}