|
1 | 1 | // |
2 | 2 | // TLS check program for CUPS. |
3 | 3 | // |
4 | | -// Copyright © 2021-2023 by OpenPrinting. |
| 4 | +// Copyright © 2021-2025 by OpenPrinting. |
5 | 5 | // Copyright © 2007-2017 by Apple Inc. |
6 | 6 | // Copyright © 1997-2006 by Easy Software Products. |
7 | 7 | // |
@@ -31,11 +31,10 @@ main(int argc, // I - Number of command-line arguments |
31 | 31 | http_t *http = NULL; // HTTP connection |
32 | 32 | const char *server = NULL; // Hostname from command-line |
33 | 33 | int port = 0; // Port number |
34 | | - char *creds; // Server credentials |
35 | | - char creds_str[2048]; // Credentials string |
36 | | - const char *cipherName; // Cipher suite name |
37 | | - int tlsVersion = 0; // TLS version number |
38 | | - char uri[1024], // Printer URI |
| 34 | + char *creds, // Server credentials |
| 35 | + creds_str[2048], // Credentials string |
| 36 | + security[256], // Security string |
| 37 | + uri[1024], // Printer URI |
39 | 38 | scheme[32], // URI scheme |
40 | 39 | host[256], // Hostname |
41 | 40 | userpass[256], // Username/password |
@@ -184,57 +183,7 @@ main(int argc, // I - Number of command-line arguments |
184 | 183 | free(creds); |
185 | 184 | } |
186 | 185 |
|
187 | | -#ifdef HAVE_OPENSSL |
188 | | - switch (SSL_version(http->tls)) |
189 | | - { |
190 | | - default : |
191 | | - tlsVersion = 0; |
192 | | - break; |
193 | | - |
194 | | - case TLS1_VERSION : |
195 | | - tlsVersion = 10; |
196 | | - break; |
197 | | - |
198 | | - case TLS1_1_VERSION : |
199 | | - tlsVersion = 11; |
200 | | - break; |
201 | | - |
202 | | - case TLS1_2_VERSION : |
203 | | - tlsVersion = 12; |
204 | | - break; |
205 | | - |
206 | | -# ifdef TLS1_3_VERSION |
207 | | - case TLS1_3_VERSION : |
208 | | - tlsVersion = 13; |
209 | | - break; |
210 | | -# endif // TLS1_3_VERSION |
211 | | - } |
212 | | - |
213 | | - cipherName = SSL_get_cipher_name(http->tls); |
214 | | - |
215 | | -#else // HAVE_GNUTLS |
216 | | - switch (gnutls_protocol_get_version(http->tls)) |
217 | | - { |
218 | | - default : |
219 | | - tlsVersion = 0; |
220 | | - break; |
221 | | - case GNUTLS_TLS1_0 : |
222 | | - tlsVersion = 10; |
223 | | - break; |
224 | | - case GNUTLS_TLS1_1 : |
225 | | - tlsVersion = 11; |
226 | | - break; |
227 | | - case GNUTLS_TLS1_2 : |
228 | | - tlsVersion = 12; |
229 | | - break; |
230 | | - case GNUTLS_TLS1_3 : |
231 | | - tlsVersion = 13; |
232 | | - break; |
233 | | - } |
234 | | - cipherName = gnutls_session_get_desc(http->tls); |
235 | | -#endif // HAVE_OPENSSL |
236 | | - |
237 | | - printf("%s: OK (TLS: %d.%d, %s)\n", server, tlsVersion / 10, tlsVersion % 10, cipherName); |
| 186 | + printf("%s: OK (%s)\n", server, httpGetSecurity(http, security, sizeof(security))); |
238 | 187 | printf(" %s\n", creds_str); |
239 | 188 |
|
240 | 189 | if (verbose) |
|
0 commit comments