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
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="/ods/default.css" />
</head>
<?vsp
declare sid, ua varchar;
declare kname, cvalue varchar;
declare cn, c, o, ou, mail, webid, pk, uname varchar;
declare days, hours any;
declare uid int;
--dbg_obj_print (params);
ua := http_request_header (http_request_header (), 'User-Agent');
sid := {?'sid'};
if (get_keyword ('pubkey', params) is not null)
{
declare exts, login any;
whenever not found goto nf;
select U_NAME, U_FULL_NAME, U_E_MAIL, WAUI_BORG, WAUI_BCOUNTRY, U_ID
into uname, cn, mail, o, c, uid
from SYS_USERS, WA_USER_INFO, VSPX_SESSION
where VS_SID = sid and VS_REALM = 'wa' and VS_UID = U_NAME and U_ID = WAUI_U_ID;
webid := sioc..person_iri (sioc..user_obj_iri (uname));
pk := replace (get_keyword ('pubkey', params), '\r\n', '');
pk := replace (pk, '\n', '');
pk := replace (pk, '\r', '');
kname := xenc_SPKI_read (null, pk);
cn := get_keyword ('cn', params, cn);
c := get_keyword ('c', params, c);
o := get_keyword ('o', params, o);
mail := get_keyword ('email', params, mail);
webid := get_keyword ('webid', params, webid);
if (length (webid))
{
webid := 'URI:' || replace (webid, ',', '%2C');
exts := vector ('subjectAltName', webid, 'nsComment', 'Virtuoso Generated Certificate');
}
else
{
exts := vector ('nsComment', 'Virtuoso Generated Certificate');
}
exts := vector_concat (exts, vector ('keyUsage', 'critical, digitalSignature,keyEncipherment',
'extendedKeyUsage', 'critical, clientAuth,emailProtection'));
days := atoi (get_keyword ('days', params, '365'));
hours := atof (get_keyword ('hours', params, '0.0'));
xenc_x509_generate ('id_rsa', kname, sequence_next ('ca_id_rsa'), days,
vector (
'CN', cn,
'C', c,
'O', o,
'emailAddress', mail
),
exts,
hours);
cvalue := xenc_pem_export (kname);
login := 1;
insert into WA_USER_CERTS (UC_U_ID, UC_CERT, UC_FINGERPRINT, UC_LOGIN, UC_TS)
values (uid, cvalue, get_certificate_info (6, cvalue, 0, ''), login, now ());
http_rewrite ();
http_header ('Content-Type: application/x-x509-user-cert\r\n');
http (decode_base64 (xenc_X509_certificate_serialize (kname)));
xenc_key_remove (kname);
return;
nf:;
}
?>
<body style="background-color: #EFEFEF;">
<?vsp
if (coalesce (strstr (ua, 'MSIE'), -1) > 0 or regexp_match ('Mozilla.*Windows.*Firefox.*\.NET CLR .*', ua) is not null)
{
declare svc_url varchar;
svc_url := (select top 1 WS_CERT_GEN_URL from DB.DBA.WA_SETTINGS);
if (length (svc_url)) {
for select U_NAME, U_FULL_NAME, U_E_MAIL, WAUI_BORG, WAUI_BCOUNTRY from SYS_USERS, VSPX_SESSION, WA_USER_INFO
where VS_SID = sid and VS_REALM = 'wa' and VS_UID = U_NAME and U_ID = WAUI_U_ID do
{
declare url varchar;
webid := sioc..person_iri (sioc..user_obj_iri (U_NAME));
url := sprintf ('%s?uri=%U&name=%U&email=%U&organization=%U',
svc_url, webid, coalesce (U_FULL_NAME, U_NAME), coalesce (U_E_MAIL, ''), coalesce (WAUI_BORG, ''));
?>
<form>
<div>
<a class="button" href='<?vsp http (url); ?>'>Generate</a>
</div>
</form>
<?vsp
}
}
else if (regexp_match ('Mozilla.*Windows.*Firefox.*\.NET CLR .*', ua) is not null)
goto make_cert;
else
{ ?>Certificate & Key Generation Not Supported. You can export a PKCS12 file produced by other browsers instead <?vsp }
}
else
{
make_cert:;
for select U_NAME, U_FULL_NAME, U_E_MAIL, WAUI_BORG, WAUI_BCOUNTRY from SYS_USERS, VSPX_SESSION, WA_USER_INFO
where VS_SID = sid and VS_REALM = 'wa' and VS_UID = U_NAME and U_ID = WAUI_U_ID do
{
cn := coalesce (U_FULL_NAME, U_NAME);
webid := sioc..person_iri (sioc..user_obj_iri (U_NAME));
mail := coalesce (U_E_MAIL, '');
o := WAUI_BORG;
c := WAUI_BCOUNTRY;
}
?>
<form>
<input type="hidden" name="sid" value="<?V {?'sid'} ?>"/>
<table border="0">
<tr>
<td nowrap="1">
Common Name:
</td>
<td>
<input type="text" name="cn" value="<?V cn ?>" size="50"/>
</td>
</tr>
<tr>
<td nowrap="1">
Country:
</td>
<td>
<input type="text" name="c" value="<?V c ?>" size="50"/>
</td>
</tr>
<tr>
<td nowrap="1">
Organization:
</td>
<td>
<input type="text" name="o" value="<?V o ?>" size="50"/>
</td>
</tr>
<tr>
<td>
E-mail:
</td>
<td>
<input type="text" name="email" value="<?V mail ?>" size="50"/>
</td>
</tr>
<tr>
<td>
WebID:
</td>
<td>
<input type="text" name="webid" value="<?V webid ?>" size="80" />
</td>
</tr>
<tr>
<td>
Key strength:
</td>
<td>
<keygen name="pubkey" />
</td>
</tr>
<tr>
<td rowspan="2">
Valid for:
</td>
<td>
<input type="text" name="hours" value="0.0" size="4"/> hours
</td>
</tr>
<tr>
<td>
<input type="text" name="days" value="<?V coalesce ((select top 1 WS_CERT_EXPIRATION_PERIOD from WA_SETTINGS), '365') ?>" size="4"/> days
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="gen" value="submit certificate request"/>
</td>
</tr>
</table>
</form>
<?vsp
}
?>
</body>
</html>
|