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
//! SSL certificate management via cPanel UAPI.
//!
//! These methods operate on a per-user basis (cPanel port **2083**) and manage
//! SSL/TLS certificates for domains.
//!
//! # Overview
//!
//! | Method | UAPI Call | Description |
//! |--------|-----------|-------------|
//! | [`CpanelClient::list_ssl_certs`] | `SSL.get_cert_info` | List all SSL certificates |
//! | [`CpanelClient::install_ssl`] | `SSL.install_cert` | Install a certificate |
//! | [`CpanelClient::delete_ssl`] | `SSL.delete_cert` | Remove a certificate |
//! | [`CpanelClient::issue_letsencrypt`] | `SSL.generate_csr` | Request Let's Encrypt cert |
//!
//! # Certificate Sources
//!
//! There are two ways to obtain SSL certificates:
//!
//! 1. **Let's Encrypt** — Free certificates issued automatically via
//! [`issue_letsencrypt`](CpanelClient::issue_letsencrypt). Requires the
//! cPanel server to have the Let's Encrypt plugin enabled.
//!
//! 2. **Manual install** — Provide your own CSR and certificate via
//! [`install_ssl`](CpanelClient::install_ssl). Useful for commercial
//! certificates (DigiCert, Let's Encrypt paid, etc.) or internal CA certs.
//!
//! # Example
//!
//! ```no_run
//! use cpanel_rs::{CpanelClient, models::{InstallSsl}};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), cpanel_rs::CpanelError> {
//! let client = CpanelClient::simple("server.example.com", 2083, "cpanel_user", "pass").unwrap();
//!
//! // List current certificates
//! let certs = client.list_ssl_certs("cpanel_user").await?;
//! for cert in &certs {
//! let expiry = cert.not_after.as_deref().unwrap_or("unknown");
//! let status = cert.active.map(|a| if a { "active" } else { "inactive" }).unwrap_or("unknown");
//! println!("{} — {} — {}", cert.domain, expiry, status);
//! }
//!
//! // Install a certificate (requires a pre-generated CSR)
//! client.install_ssl("cpanel_user", &InstallSsl {
//! domain: "example.com".into(),
//! csr: "-----BEGIN CERTIFICATE REQUEST-----\nMIIC...".into(),
//! cert: "-----BEGIN CERTIFICATE-----\nMIID...".into(),
//! ca: Some("-----BEGIN CERTIFICATE-----\nMIID...".into()),
//! bundle: Some(true),
//! }).await?;
//!
//! // Or request a free Let's Encrypt certificate
//! client.issue_letsencrypt("cpanel_user", "example.com").await?;
//!
//! Ok(())
//! }
//! ```
use crate::;
use Deserialize;
/// A list of SSL certificates as returned by [`list_ssl_certs`](CpanelClient::list_ssl_certs).