Skip to content

Commit 2aa119a

Browse files
committed
Update cups-oauth and cups-x509 man pages.
1 parent 49cd644 commit 2aa119a

5 files changed

Lines changed: 103 additions & 45 deletions

File tree

doc/cups-oauth.html

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,35 +196,35 @@ <h2 id="cups-oauth-1.options">Options</h2>
196196
</p>
197197
<p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>-s </strong><em>SCOPE(S)</em><br>
198198
Specifies a space-delimited list of scope names to use when authorizing access.
199-
The default is to request authorization for all supported scopes.
199+
The default is to request authorization for all supported OpenID scopes.
200200
</p>
201-
<h2 id="cups-oauth-1.commands">Commands</h2>
202-
<h3 id="cups-oauth-1.commands.authorize">Authorize</h3>
201+
<h2 id="cups-oauth-1.sub-commands">Sub-Commands</h2>
202+
<h3 id="cups-oauth-1.sub-commands.authorize">Authorize</h3>
203203
<p>Starts an authorization workflow with the default web browser.
204204
If a resource URI is specified, the authorization is specific to that resource.
205205
The access token is send to the standard output on success.
206206
</p>
207-
<h3 id="cups-oauth-1.commands.clear">Clear</h3>
207+
<h3 id="cups-oauth-1.sub-commands.clear">Clear</h3>
208208
<p>Clears any authorization for the specified resource or for all resources if no resource URI is supplied.
209209
</p>
210-
<h3 id="cups-oauth-1.commands.get-access-token">Get-Access-Token</h3>
210+
<h3 id="cups-oauth-1.sub-commands.get-access-token">Get-Access-Token</h3>
211211
<p>Output the current, unexpired access token, if any, to the standard output.
212212
</p>
213-
<h3 id="cups-oauth-1.commands.get-client-id">Get-Client-Id</h3>
213+
<h3 id="cups-oauth-1.sub-commands.get-client-id">Get-Client-Id</h3>
214214
<p>Output the client ID string, if any, to the standard output.
215215
</p>
216-
<h3 id="cups-oauth-1.commands.get-metadata">Get-Metadata</h3>
216+
<h3 id="cups-oauth-1.sub-commands.get-metadata">Get-Metadata</h3>
217217
<p>Get the OAuth/OpenID authorization server metadata and send it to the standard output.
218218
If a name is specified, the output is just the value for the specified metadata.
219219
</p>
220-
<h3 id="cups-oauth-1.commands.get-user-id">Get-User-Id</h3>
220+
<h3 id="cups-oauth-1.sub-commands.get-user-id">Get-User-Id</h3>
221221
<p>Get the OpenID user ID information and send it to the standard output.
222222
If a name is specified, the output is just the named claim from the user ID.
223223
</p>
224-
<h3 id="cups-oauth-1.commands.set-access-token">Set-Access-Token</h3>
224+
<h3 id="cups-oauth-1.sub-commands.set-access-token">Set-Access-Token</h3>
225225
<p>Set the access token (which is sometimes also called an API key) for the specified resource or for all resources.
226226
</p>
227-
<h3 id="cups-oauth-1.commands.set-client-data">Set-Client-Data</h3>
227+
<h3 id="cups-oauth-1.sub-commands.set-client-data">Set-Client-Data</h3>
228228
<p>Set the client ID string and secret for an OAuth/OpenID authorization server.
229229
</p>
230230
<h2 id="cups-oauth-1.environment-variables">Environment Variables</h2>
@@ -240,8 +240,18 @@ <h2 id="cups-oauth-1.notes">Notes</h2>
240240
<p>CUPS uses a redirect URI of &quot;<a href="http://127.0.0.1/&quot;">http://127.0.0.1/&quot;</a> for all authorization on the local system.
241241
</p>
242242
<h2 id="cups-oauth-1.examples">Examples</h2>
243-
<p>TBD
243+
<p>Register a client ID and secret for the OAuth server at &quot;<a href="https://oauth.example.com/&quot;:">https://oauth.example.com/&quot;:</a>
244244
</p>
245+
<pre> cups-oauth -a <a href="https://oauth.example.com/">https://oauth.example.com/</a> set-client-data CLIENT-ID CLIENT-SECRET
246+
</pre>
247+
<p>Save an access token (sometimes called an application or API key) for the OAuth server at &quot;<a href="https://oauth.example.com/&quot;:">https://oauth.example.com/&quot;:</a>
248+
</p>
249+
<pre> cups-oauth -a <a href="https://oauth.example.com/">https://oauth.example.com/</a> set-access-token TOKEN
250+
</pre>
251+
<p>Authorize against the OAuth server at &quot;<a href="https://oauth.example.com/&quot;">https://oauth.example.com/&quot;</a> using your web browser:
252+
</p>
253+
<pre> cups-oauth -a <a href="https://oauth.example.com/">https://oauth.example.com/</a> authorize
254+
</pre>
245255
<h2 id="cups-oauth-1.see-also">See Also</h2>
246256
<p><strong>cups</strong>(1)
247257

doc/cups-x509.html

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ <h2 id="cups-x509-1.synopsis">Synopsis</h2>
148148
<strong>-u</strong>
149149
<em>USAGE</em>
150150
]
151-
<em>COMMAND</em>
151+
<em>SUB-COMMAND</em>
152152
<em>[ARGUMENT(S)]</em>
153153
</p>
154154
<h2 id="cups-x509-1.description">Description</h2>
@@ -214,32 +214,46 @@ <h2 id="cups-x509-1.options">Options</h2>
214214
The supported uses are &quot;digitalSignature&quot;, &quot;nonRepudiation&quot;, &quot;keyEncipherment&quot;, &quot;dataEncipherment&quot;, &quot;keyAgreement&quot;, &quot;keyCertSign&quot;, &quot;cRLSign&quot;, &quot;encipherOnly&quot;, and &quot;decipherOnly&quot;.
215215
The preset &quot;default-ca&quot; specifies those uses required for a Certificate Authority, and the preset &quot;default-tls&quot; specifies those uses required for TLS.
216216
</p>
217-
<h2 id="cups-x509-1.commands">Commands</h2>
218-
<h3 id="cups-x509-1.commands.ca-common-name">Ca Common-Name</h3>
217+
<h2 id="cups-x509-1.sub-commands">Sub-Commands</h2>
218+
<h3 id="cups-x509-1.sub-commands.ca-common-name">Ca Common-Name</h3>
219219
<p>Sign a certificate request for the specified common name.
220220
</p>
221-
<h3 id="cups-x509-1.commands.cacert-common-name">Cacert Common-Name</h3>
221+
<h3 id="cups-x509-1.sub-commands.cacert-common-name">Cacert Common-Name</h3>
222222
<p>Create a CA certificate for the specified common name.
223223
</p>
224-
<h3 id="cups-x509-1.commands.cert-common-name">Cert Common-Name</h3>
224+
<h3 id="cups-x509-1.sub-commands.cert-common-name">Cert Common-Name</h3>
225225
<p>Create a certificate for the specified common name.
226226
</p>
227-
<h3 id="cups-x509-1.commands.client-uri">Client Uri</h3>
227+
<h3 id="cups-x509-1.sub-commands.client-uri">Client Uri</h3>
228228
<p>Connect to the specified URI and validate the server's certificate.
229229
</p>
230-
<h3 id="cups-x509-1.commands.csr-common-name">Csr Common-Name</h3>
230+
<h3 id="cups-x509-1.sub-commands.csr-common-name">Csr Common-Name</h3>
231231
<p>Create a certificate signing request for the specified common name.
232232
</p>
233-
<h3 id="cups-x509-1.commands.server-common-nameport">Server Common-Name[:Port]</h3>
233+
<h3 id="cups-x509-1.sub-commands.server-common-nameport">Server Common-Name[:Port]</h3>
234234
<p>Run a HTTPS test server that echos back the resource path for every GET request.
235235
If PORT is not specified, uses a port number from 8000 to 8999.
236236
</p>
237-
<h3 id="cups-x509-1.commands.show-common-name">Show Common-Name</h3>
237+
<h3 id="cups-x509-1.sub-commands.show-common-name">Show Common-Name</h3>
238238
<p>Shows any stored credentials for the specified common name.
239239
</p>
240240
<h2 id="cups-x509-1.examples">Examples</h2>
241-
<p>TBD
241+
<p>Create a certificate signing request for a 384-bit ECDSA certificate for &quot;server.example.com&quot;:
242242
</p>
243+
<pre> cups-x509 csr -t ecdsa-p384 server.example.com
244+
</pre>
245+
<p>Install the certificate you get back from the CA for &quot;server.example.com&quot;:
246+
</p>
247+
<pre> cups-x509 install server.example.com server.example.com.crt
248+
</pre>
249+
<p>Run a test server for &quot;server.exmaple.com&quot; on port 8080:
250+
</p>
251+
<pre> cups-x509 server SERVER-NAME:8080
252+
</pre>
253+
<p>Test a HTTPS client connection to &quot;www.example.com&quot; with validation:
254+
</p>
255+
<pre> cups-x509 client --require-ca <a href="https://www.example.com/">https://www.example.com/</a>
256+
</pre>
243257
<h2 id="cups-x509-1.see-also">See Also</h2>
244258
<p><strong>cups</strong>(1)
245259

man/cups-oauth.1

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
.\" Licensed under Apache License v2.0. See the file "LICENSE" for more
77
.\" information.
88
.\"
9-
.TH cups-oauth 1 "CUPS" "2025-03-04" "OpenPrinting"
9+
.TH cups-oauth 1 "CUPS" "2025-05-05" "OpenPrinting"
1010
.SH NAME
1111
cups-oauth \- interact with an oauth/openid authorization server
1212
.SH SYNOPSIS
@@ -104,8 +104,8 @@ Specifies the OAuth/OpenID authorization server URL.
104104
.TP 5
105105
\fB\-s \fISCOPE(S)\fR
106106
Specifies a space-delimited list of scope names to use when authorizing access.
107-
The default is to request authorization for all supported scopes.
108-
.SH COMMANDS
107+
The default is to request authorization for all supported OpenID scopes.
108+
.SH SUB-COMMANDS
109109
.SS authorize
110110
Starts an authorization workflow with the default web browser.
111111
If a resource URI is specified, the authorization is specific to that resource.
@@ -137,7 +137,18 @@ environment variable sets the default OAuth/OpenID scopes as a space-delimited l
137137
.SH NOTES
138138
CUPS uses a redirect URI of "http://127.0.0.1/" for all authorization on the local system.
139139
.SH EXAMPLES
140-
TBD
140+
Register a client ID and secret for the OAuth server at "https://oauth.example.com/":
141+
.nf
142+
cups-oauth -a https://oauth.example.com/ set-client-data CLIENT-ID CLIENT-SECRET
143+
.fi
144+
Save an access token (sometimes called an application or API key) for the OAuth server at "https://oauth.example.com/":
145+
.nf
146+
cups-oauth -a https://oauth.example.com/ set-access-token TOKEN
147+
.fi
148+
Authorize against the OAuth server at "https://oauth.example.com/" using your web browser:
149+
.nf
150+
cups-oauth -a https://oauth.example.com/ authorize
151+
.fi
141152
.SH SEE ALSO
142153
.BR cups (1)
143154
.SH COPYRIGHT

man/cups-x509.1

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
.\" Licensed under Apache License v2.0. See the file "LICENSE" for more
77
.\" information.
88
.\"
9-
.TH cups-x509 1 "CUPS" "2025-03-04" "OpenPrinting"
9+
.TH cups-x509 1 "CUPS" "2025-05-05" "OpenPrinting"
1010
.SH NAME
1111
cups-x509 \- description
1212
.SH SYNOPSIS
@@ -58,7 +58,7 @@ cups-x509 \- description
5858
.B \-u
5959
.I USAGE
6060
]
61-
.I COMMAND
61+
.I SUB-COMMAND
6262
.I [ARGUMENT(S)]
6363
.SH DESCRIPTION
6464
The
@@ -121,7 +121,7 @@ Specify the certificate type - "rsa-2048" for 2048-bit RSA, "rsa-3072" for 3072-
121121
Specify the usage for the certificate as a comma-delimited list of uses.
122122
The supported uses are "digitalSignature", "nonRepudiation", "keyEncipherment", "dataEncipherment", "keyAgreement", "keyCertSign", "cRLSign", "encipherOnly", and "decipherOnly".
123123
The preset "default-ca" specifies those uses required for a Certificate Authority, and the preset "default-tls" specifies those uses required for TLS.
124-
.SH COMMANDS
124+
.SH SUB-COMMANDS
125125
.SS ca COMMON-NAME
126126
Sign a certificate request for the specified common name.
127127
.SS cacert COMMON-NAME
@@ -138,7 +138,22 @@ If PORT is not specified, uses a port number from 8000 to 8999.
138138
.SS show COMMON-NAME
139139
Shows any stored credentials for the specified common name.
140140
.SH EXAMPLES
141-
TBD
141+
Create a certificate signing request for a 384-bit ECDSA certificate for "server.example.com":
142+
.nf
143+
cups-x509 csr -t ecdsa-p384 server.example.com
144+
.fi
145+
Install the certificate you get back from the CA for "server.example.com":
146+
.nf
147+
cups-x509 install server.example.com server.example.com.crt
148+
.fi
149+
Run a test server for "server.exmaple.com" on port 8080:
150+
.nf
151+
cups-x509 server SERVER-NAME:8080
152+
.fi
153+
Test a HTTPS client connection to "www.example.com" with validation:
154+
.nf
155+
cups-x509 client --require-ca https://www.example.com/
156+
.fi
142157
.SH SEE ALSO
143158
.BR cups (1)
144159
.SH COPYRIGHT

tools/cups-x509.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
static int do_ca(const char *common_name, const char *csrfile, const char *root_name, int days);
6969
static int do_cert(bool ca_cert, cups_credpurpose_t purpose, cups_credtype_t type, cups_credusage_t keyusage, const char *organization, const char *org_unit, const char *locality, const char *state, const char *country, const char *root_name, const char *common_name, size_t num_alt_names, const char **alt_names, int days);
70-
static int do_client(const char *uri);
70+
static int do_client(const char *uri, bool pin, bool require_ca);
7171
static int do_csr(cups_credpurpose_t purpose, cups_credtype_t type, cups_credusage_t keyusage, const char *organization, const char *org_unit, const char *locality, const char *state, const char *country, const char *common_name, size_t num_alt_names, const char **alt_names);
7272
static int do_server(const char *host_port);
7373
static int do_show(const char *common_name);
@@ -94,6 +94,8 @@ main(int argc, // I - Number of command-line arguments
9494
*state = NULL, // State/province
9595
*country = NULL, // Country
9696
*alt_names[100]; // Subject alternate names
97+
bool pin = false, // Pin client cert?
98+
require_ca = false; // Require a CA-signed cert?
9799
size_t num_alt_names = 0;
98100
int days = 365; // Days until expiration
99101
cups_credpurpose_t purpose = CUPS_CREDPURPOSE_SERVER_AUTH;
@@ -111,6 +113,14 @@ main(int argc, // I - Number of command-line arguments
111113
{
112114
return (usage(stdout));
113115
}
116+
else if (!strcmp(argv[i], "--pin"))
117+
{
118+
pin = true;
119+
}
120+
else if (!strcmp(argv[i], "--require-ca"))
121+
{
122+
require_ca = true;
123+
}
114124
else if (!strcmp(argv[i], "--version"))
115125
{
116126
puts(LIBCUPS_VERSION);
@@ -355,7 +365,7 @@ main(int argc, // I - Number of command-line arguments
355365

356366
if (!command || !arg)
357367
{
358-
cupsLangPuts(stderr, _("cups-x509: Missing command argument."));
368+
cupsLangPuts(stderr, _("cups-x509: Missing sub-command argument."));
359369
return (usage(stderr));
360370
}
361371

@@ -374,7 +384,7 @@ main(int argc, // I - Number of command-line arguments
374384
}
375385
else if (!strcmp(command, "client"))
376386
{
377-
return (do_client(arg));
387+
return (do_client(arg, pin, require_ca));
378388
}
379389
else if (!strcmp(command, "csr"))
380390
{
@@ -539,7 +549,9 @@ do_cert(
539549
//
540550

541551
static int // O - Exit status
542-
do_client(const char *uri) // I - URI
552+
do_client(const char *uri, // I - URI
553+
bool pin, // I - Pin the cert?
554+
bool require_ca) // I - Require a CA-signed cert?
543555
{
544556
http_t *http; // HTTP connection
545557
char scheme[HTTP_MAX_URI], // Scheme from URI
@@ -556,26 +568,19 @@ do_client(const char *uri) // I - URI
556568

557569

558570
// Connect to the host and validate credentials...
559-
if (httpSeparateURI(HTTP_URI_CODING_MOST, uri, scheme, sizeof(scheme), username, sizeof(username), hostname, sizeof(hostname), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
571+
if ((http = httpConnectURI(uri, hostname, sizeof(hostname), &port, resource, sizeof(resource), /*blocking*/true, /*msec*/30000, /*cancel*/NULL, require_ca)) == NULL)
560572
{
561-
cupsLangPrintf(stderr, _("cups-x509: Bad URI '%s'."), uri);
562-
return (1);
563-
}
564-
565-
if ((http = httpConnect(hostname, port, NULL, AF_UNSPEC, HTTP_ENCRYPTION_ALWAYS, 1, 30000, NULL)) == NULL)
566-
{
567-
cupsLangPrintf(stderr, _("cups-x509: Unable to connect to '%s' on port %d: %s"), hostname, port, cupsGetErrorString());
573+
cupsLangPrintf(stderr, _("cups-x509: Unable to connect to '%s': %s"), uri, cupsGetErrorString());
568574
return (1);
569575
}
570576

571577
puts("TLS Server Credentials:");
572578
if ((hcreds = httpCopyPeerCredentials(http)) != NULL)
573579
{
574-
trust = cupsGetCredentialsTrust(/*path*/NULL, hostname, hcreds, /*require_ca*/false);
580+
trust = cupsGetCredentialsTrust(/*path*/NULL, hostname, hcreds, require_ca);
575581

576582
cupsGetCredentialsInfo(hcreds, hinfo, sizeof(hinfo));
577583

578-
// printf(" Certificate Count: %u\n", (unsigned)cupsArrayGetCount(hcreds));
579584
if (trust == HTTP_TRUST_OK)
580585
puts(" Trust: OK");
581586
else
@@ -584,6 +589,9 @@ do_client(const char *uri) // I - URI
584589
printf(" ValidName: %s\n", cupsAreCredentialsValidForName(hostname, hcreds) ? "true" : "false");
585590
printf(" Info: \"%s\"\n", hinfo);
586591

592+
if (pin)
593+
cupsSaveCredentials(/*path*/NULL, hostname, hcreds, /*key*/NULL);
594+
587595
free(hcreds);
588596
}
589597
else
@@ -835,9 +843,9 @@ do_show(const char *common_name) // I - Common name
835843
static int // O - Exit code
836844
usage(FILE *out) // I - Output file (stdout or stderr)
837845
{
838-
cupsLangPuts(out, _("Usage: cups-x509 [OPTIONS] [COMMAND] [ARGUMENT]"));
846+
cupsLangPuts(out, _("Usage: cups-x509 [OPTIONS] [SUB-COMMAND] [ARGUMENT]"));
839847
cupsLangPuts(out, "");
840-
cupsLangPuts(out, _("Commands:"));
848+
cupsLangPuts(out, _("Sub-Commands:"));
841849
cupsLangPuts(out, "");
842850
cupsLangPuts(out, _("ca COMMON-NAME Sign a CSR to produce a certificate."));
843851
cupsLangPuts(out, _("cacert COMMON-NAME Create a CA certificate."));

0 commit comments

Comments
 (0)