master
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24/* <DESC>
25 * Shows HTTPS usage with client certs and optional SSL engine use.
26 * </DESC>
27 */
28#ifdef _MSC_VER
29#ifndef _CRT_SECURE_NO_WARNINGS
30#define _CRT_SECURE_NO_WARNINGS /* for fopen() */
31#endif
32#endif
34#include <stdio.h>
36#include <curl/curl.h>
38/* some requirements for this to work:
39 1. set pCertFile to the file with the client certificate
40 2. if the key is passphrase protected, set pPassphrase to the
41 passphrase you use
42 3. if you are using a crypto engine:
43 3.1. set a #define USE_ENGINE
44 3.2. set pEngine to the name of the crypto engine you use
45 3.3. set pKeyName to the key identifier you want to use
46 4. if you do not use a crypto engine:
47 4.1. set pKeyName to the filename of your client key
48 4.2. if the format of the key file is DER, set pKeyType to "DER"
49 */
51int main(void)
52{
53 CURL *curl = NULL;
54 CURLcode result;
55 FILE *headerfile;
56 const char *pPassphrase = NULL;
58 static const char pCertFile[] = "testcert.pem";
59 static const char pCACertFile[] = "cacert.pem";
60 static const char pHeaderFile[] = "dumpit";
62 const char *pKeyName;
63 const char *pKeyType;
65#ifdef USE_ENGINE
66 pKeyName = "rsa_test";
67 pKeyType = "ENG";
68#else
69 pKeyName = "testkey.pem";
70 pKeyType = "PEM";
71#endif
73 result = curl_global_init(CURL_GLOBAL_ALL);
74 if(result != CURLE_OK) {
75 return (int)result;
76 }
78 headerfile = fopen(pHeaderFile, "wb");
79 if(!headerfile)
80 goto error;
82 curl = curl_easy_init();
83 if(!curl)
84 goto error;
86 /* what call to write: */
87 curl_easy_setopt(curl, CURLOPT_URL, "https://secure.site.example/");
88 curl_easy_setopt(curl, CURLOPT_HEADERDATA, headerfile);
90#ifdef USE_ENGINE
91 /* use crypto engine. nCipher HSM... */
92 if(curl_easy_setopt(curl, CURLOPT_SSLENGINE, "chil") != CURLE_OK) {
93 /* load the crypto engine */
94 fprintf(stderr, "cannot set crypto engine\n");
95 goto error;
96 }
97 if(curl_easy_setopt(curl, CURLOPT_SSLENGINE_DEFAULT, 1L) != CURLE_OK) {
98 /* set the crypto engine as default */
99 /* only needed for the first time you load
100 an engine in a curl object... */
101 fprintf(stderr, "cannot set crypto engine as default\n");
102 goto error;
103 }
104#endif
106 /* cert is stored PEM coded in file... */
107 /* since PEM is default, we need not set it for PEM */
108 curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
110 /* set the cert for client authentication */
111 curl_easy_setopt(curl, CURLOPT_SSLCERT, pCertFile);
113 /* sorry, for engine we must set the passphrase
114 (if the key has one...) */
115 if(pPassphrase)
116 curl_easy_setopt(curl, CURLOPT_KEYPASSWD, pPassphrase);
118 /* if we use a key stored in a crypto engine,
119 we must set the key type to "ENG" */
120 curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, pKeyType);
122 /* set the private key (file or ID in engine) */
123 curl_easy_setopt(curl, CURLOPT_SSLKEY, pKeyName);
125 /* set the file with the certs validating the server */
126 curl_easy_setopt(curl, CURLOPT_CAINFO, pCACertFile);
128 /* disconnect if we cannot validate server's cert */
129 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
131 /* Perform the request, result gets the return code */
132 result = curl_easy_perform(curl);
133 /* Check for errors */
134 if(result != CURLE_OK)
135 fprintf(stderr, "curl_easy_perform() failed: %s\n",
136 curl_easy_strerror(result));
138error:
140 /* always cleanup */
141 if(curl)
142 curl_easy_cleanup(curl);
144 if(headerfile)
145 fclose(headerfile);
147 curl_global_cleanup();
149 return (int)result;
150}
Diagnostics4 git calls · 48 ms
CallStatusSizeTime048 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2001.8 KiB · hit43 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=43 git.response.bytes=1881 git.response.cache=HIT git.response.duration_ms=43 git.fetch.wants=45db65a05d01a206987cb619fcb7390dcdd0ef88 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1881 git.pkt.payload.max=1860 git.sideband.band1.bytes=1859 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e2c555d8414afc
- Request
- ffee458f…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format