2019-01-14 21:08:46 +03:00
|
|
|
/- asn1, hall
|
2018-08-30 01:07:21 +03:00
|
|
|
/+ base64, der, primitive-rsa, *pkcs, *jose
|
2018-04-27 23:31:18 +03:00
|
|
|
=, eyre
|
2018-08-29 03:58:23 +03:00
|
|
|
=* rsa primitive-rsa
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-05-25 10:28:26 +03:00
|
|
|
|%
|
|
|
|
:: +en-base64url: url-safe base64 encoding, without padding
|
2018-04-30 19:17:53 +03:00
|
|
|
::
|
2018-05-25 10:28:26 +03:00
|
|
|
++ en-base64url
|
|
|
|
~(en base64 | &)
|
|
|
|
:: +de-base64url: url-safe base64 decoding, without padding
|
2018-04-30 19:17:53 +03:00
|
|
|
::
|
|
|
|
++ de-base64url
|
|
|
|
~(de base64 | &)
|
2019-06-25 07:25:35 +03:00
|
|
|
:: +join-turf
|
|
|
|
::
|
|
|
|
++ join-turf
|
|
|
|
|= hot=(list turf)
|
|
|
|
^- cord
|
|
|
|
%+ rap 3
|
|
|
|
%- (bake join ,[cord wain])
|
|
|
|
[', ' (turn hot en-turf:html)]
|
2018-06-26 08:10:19 +03:00
|
|
|
:: |octn: encode/decode unsigned atoms as big-endian octet stream
|
|
|
|
::
|
|
|
|
++ octn
|
|
|
|
|%
|
|
|
|
++ en |=(a=@u `octs`[(met 3 a) (swp 3 a)])
|
|
|
|
++ de |=(a=octs `@u`(rev 3 p.a q.a))
|
|
|
|
--
|
2018-11-02 08:10:37 +03:00
|
|
|
:: |body: acme api response body types
|
|
|
|
::
|
|
|
|
++ body
|
|
|
|
|%
|
2019-06-19 05:38:45 +03:00
|
|
|
+$ acct [wen=@t sas=@t]
|
2018-11-02 08:10:37 +03:00
|
|
|
::
|
|
|
|
+$ order
|
|
|
|
$: exp=@t
|
|
|
|
sas=@t
|
|
|
|
aut=(list purl)
|
|
|
|
fin=(unit purl)
|
|
|
|
cer=(unit purl)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ auth
|
|
|
|
$: dom=turf
|
|
|
|
sas=@t
|
|
|
|
exp=@t
|
|
|
|
cal=challenge
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ challenge [typ=@t sas=@t url=purl tok=@t err=(unit error)]
|
|
|
|
::
|
|
|
|
+$ error [type=@t detail=@t]
|
|
|
|
--
|
2018-05-25 10:28:26 +03:00
|
|
|
::
|
2018-11-01 09:54:30 +03:00
|
|
|
:: |grab: acme api response json reparsers
|
2018-05-18 01:10:24 +03:00
|
|
|
::
|
2018-05-15 07:26:59 +03:00
|
|
|
++ grab
|
2018-04-19 09:27:55 +03:00
|
|
|
=, dejs:format
|
2018-05-15 07:26:59 +03:00
|
|
|
|%
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +json-purl: parse url
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2018-05-15 07:26:59 +03:00
|
|
|
++ json-purl (su auri:de-purl:html)
|
2018-11-02 08:10:37 +03:00
|
|
|
:: +json-date: parse iso-8601
|
|
|
|
::
|
|
|
|
:: XX actually parse
|
|
|
|
::
|
|
|
|
++ json-date so
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +directory: parse ACME service directory
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
|
|
|
++ directory
|
|
|
|
%- ot
|
2018-11-02 08:10:37 +03:00
|
|
|
:~ 'newAccount'^json-purl
|
|
|
|
'newNonce'^json-purl
|
|
|
|
'newOrder'^json-purl
|
|
|
|
'revokeCert'^json-purl
|
|
|
|
'keyChange'^json-purl
|
2018-05-15 07:26:59 +03:00
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +acct: parse ACME service account
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
|
|
|
++ acct
|
2018-11-02 08:10:37 +03:00
|
|
|
^- $-(json acct:body)
|
|
|
|
:: ignoring key, contact, initialIp
|
|
|
|
::
|
2019-06-19 05:38:45 +03:00
|
|
|
(ot 'createdAt'^json-date 'status'^so ~)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +order: parse certificate order
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
|
|
|
++ order
|
2018-11-02 08:10:37 +03:00
|
|
|
^- $-(json order:body)
|
|
|
|
%- ou
|
|
|
|
:~ 'expires'^(un json-date)
|
|
|
|
'status'^(un so)
|
|
|
|
'authorizations'^(uf ~ (ar json-purl))
|
|
|
|
'finalize'^(uf ~ (mu json-purl))
|
|
|
|
'certificate'^(uf ~ (mu json-purl))
|
2018-05-15 07:26:59 +03:00
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +auth: parse authorization
|
|
|
|
::
|
2018-05-15 07:26:59 +03:00
|
|
|
++ auth
|
|
|
|
=> |%
|
2018-11-02 08:10:37 +03:00
|
|
|
:: +iden: extract +turf from service identifier
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2018-05-15 07:26:59 +03:00
|
|
|
++ iden
|
|
|
|
|= [typ=@t hot=host]
|
2018-11-02 08:10:37 +03:00
|
|
|
^- turf
|
2018-05-15 07:26:59 +03:00
|
|
|
?>(&(?=(%dns typ) ?=([%& *] hot)) p.hot)
|
2018-11-02 08:10:37 +03:00
|
|
|
:: +http-trial: extract %http-01 challenge
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
|
|
|
++ trial
|
2018-11-02 08:10:37 +03:00
|
|
|
|= a=(list challenge:body)
|
|
|
|
^- challenge:body
|
|
|
|
=/ b (skim a |=([typ=@t *] ?=(%http-01 typ)))
|
2018-05-15 07:26:59 +03:00
|
|
|
?>(?=(^ b) i.b)
|
|
|
|
--
|
2018-11-02 08:10:37 +03:00
|
|
|
^- $-(json auth:body)
|
2018-05-15 07:26:59 +03:00
|
|
|
%- ot
|
2018-11-02 08:10:37 +03:00
|
|
|
:~ 'identifier'^(cu iden (ot type+so value+(su thos:de-purl:html) ~))
|
|
|
|
'status'^so
|
|
|
|
'expires'^json-date
|
|
|
|
'challenges'^(cu trial (ar challenge))
|
2018-05-15 23:52:54 +03:00
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +challenge: parse domain validation challenge
|
2018-05-15 23:52:54 +03:00
|
|
|
::
|
|
|
|
++ challenge
|
2018-11-02 08:10:37 +03:00
|
|
|
^- $-(json challenge:body)
|
|
|
|
%- ou
|
|
|
|
:~ 'type'^(un so)
|
|
|
|
'status'^(un so)
|
|
|
|
'url'^(un json-purl)
|
|
|
|
'token'^(un so)
|
|
|
|
'error'^(uf ~ (mu error))
|
2018-05-15 07:26:59 +03:00
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +error: parse ACME service error response
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
|
|
|
++ error
|
2018-11-02 08:10:37 +03:00
|
|
|
^- $-(json error:body)
|
|
|
|
(ot type+so detail+so ~)
|
2018-05-15 07:26:59 +03:00
|
|
|
--
|
2018-04-19 09:27:55 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
:::: acme state
|
|
|
|
::
|
|
|
|
|%
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +move: output effect
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-14 20:49:27 +03:00
|
|
|
+$ move [bone card]
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +card: output effect payload
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-14 20:49:27 +03:00
|
|
|
+$ card
|
2019-07-04 09:09:44 +03:00
|
|
|
$% [%connect wire =binding:eyre app=term]
|
2019-03-19 00:05:26 +03:00
|
|
|
[%http-response =http-event:http]
|
2019-01-14 21:08:46 +03:00
|
|
|
[%poke wire dock poke]
|
2019-07-04 09:45:54 +03:00
|
|
|
[%request wire request:http outbound-config:iris]
|
2018-11-07 02:25:07 +03:00
|
|
|
[%rule wire %cert (unit [wain wain])]
|
2018-06-29 03:03:16 +03:00
|
|
|
[%wait wire @da]
|
2018-06-23 06:43:41 +03:00
|
|
|
==
|
2019-01-14 21:08:46 +03:00
|
|
|
:: +poke: outgoing app pokes
|
|
|
|
::
|
|
|
|
+$ poke
|
|
|
|
$% [%hall-action %phrase audience:hall (list speech:hall)]
|
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +nonce-next: next effect to emit upon receiving nonce
|
2018-06-27 00:53:29 +03:00
|
|
|
::
|
2019-01-14 20:49:27 +03:00
|
|
|
+$ nonce-next
|
2018-06-27 00:53:29 +03:00
|
|
|
$? %register
|
|
|
|
%new-order
|
|
|
|
%finalize-order
|
|
|
|
%finalize-trial
|
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +acct: an ACME service account
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-14 20:49:27 +03:00
|
|
|
+$ acct
|
2018-11-01 09:54:30 +03:00
|
|
|
$: :: key: account keypair
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
key=key:rsa
|
2018-11-01 09:54:30 +03:00
|
|
|
:: reg: account registration
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX wen=@da once parser is fixed
|
|
|
|
::
|
|
|
|
reg=(unit [wen=@t kid=@t])
|
2018-06-23 06:43:41 +03:00
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +config: finalized configuration
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-14 20:49:27 +03:00
|
|
|
+$ config
|
2018-11-01 09:54:30 +03:00
|
|
|
$: :: dom: domains
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
dom=(set turf)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: key: certificate keypair
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
key=key:rsa
|
2018-11-01 09:54:30 +03:00
|
|
|
:: cer: signed certificate
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
cer=wain
|
2018-11-01 09:54:30 +03:00
|
|
|
:: exp: expiration date
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
exp=@da
|
2018-11-01 09:54:30 +03:00
|
|
|
:: dor: source ACME service order URL
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
dor=purl
|
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +trial: domain validation challenge
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-14 20:49:27 +03:00
|
|
|
+$ trial
|
2018-11-01 09:54:30 +03:00
|
|
|
$% :: %http only for now
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
$: %http
|
2018-11-01 09:54:30 +03:00
|
|
|
:: ego: ACME service challenge url
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
ego=purl
|
2018-11-01 09:54:30 +03:00
|
|
|
:: tok: challenge token
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
tok=@t
|
2018-11-01 09:54:30 +03:00
|
|
|
:: sas: challenge status
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
sas=?(%recv %pend %auth)
|
|
|
|
== ==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +auth: domain authorization
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-14 20:49:27 +03:00
|
|
|
+$ auth
|
2018-11-01 09:54:30 +03:00
|
|
|
$: :: ego: ACME service authorization url
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
ego=purl
|
2018-11-01 09:54:30 +03:00
|
|
|
:: dom: domain under authorization
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
dom=turf
|
2018-11-01 09:54:30 +03:00
|
|
|
:: cal: domain validation challenge
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
cal=trial
|
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +order-auth: domain authorization state for order processing
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-14 20:49:27 +03:00
|
|
|
+$ order-auth
|
2018-11-01 09:54:30 +03:00
|
|
|
$: :: pending: remote authorization urls
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
pending=(list purl)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: active: authorization in progress
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
active=(unit [idx=@ auth])
|
2018-11-01 09:54:30 +03:00
|
|
|
:: done: finalized authorizations (XX or failed?)
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
done=(list auth)
|
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +order: ACME certificate order
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-14 20:49:27 +03:00
|
|
|
+$ order
|
2018-11-01 09:54:30 +03:00
|
|
|
$: :: dom: domains
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
dom=(set turf)
|
2019-01-15 01:58:18 +03:00
|
|
|
:: try: attempt number
|
|
|
|
::
|
|
|
|
try=@ud
|
2018-11-01 09:54:30 +03:00
|
|
|
:: sas: order state
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
sas=$@(%wake [%rest wen=@da])
|
2018-11-01 09:54:30 +03:00
|
|
|
:: exp: expiration date
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX @da once ISO-8601 parser
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
exp=@t
|
2018-11-01 09:54:30 +03:00
|
|
|
:: ego: ACME service order url
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
ego=purl
|
2018-11-01 09:54:30 +03:00
|
|
|
:: fin: ACME service order finalization url
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
fin=purl
|
2018-11-01 09:54:30 +03:00
|
|
|
:: key: certificate keypair
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
key=key:rsa
|
2018-11-01 09:54:30 +03:00
|
|
|
:: csr: DER-encoded PKCS10 certificate signing request
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
csr=@ux
|
2018-11-01 09:54:30 +03:00
|
|
|
:: aut: authorizations required by this order
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
aut=order-auth
|
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +history: archive of past ACME service interactions
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-14 20:49:27 +03:00
|
|
|
+$ history
|
2018-11-01 09:54:30 +03:00
|
|
|
$: :: act: list of revoked account keypairs
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
act=(list acct)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: fig: list of expired configurations
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
fig=(list config)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: fal: list of failed order attempts
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
fal=(list order)
|
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +directory: ACME v2 service directory
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-14 20:49:27 +03:00
|
|
|
+$ directory
|
2019-01-11 20:28:29 +03:00
|
|
|
$: :: register: registration url (newAccount)
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-11 20:28:29 +03:00
|
|
|
register=purl
|
|
|
|
:: nonce: nonce creation url (newNonce)
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-11 20:28:29 +03:00
|
|
|
nonce=purl
|
|
|
|
:: new-order: order creation url (newOrder)
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-11 20:28:29 +03:00
|
|
|
new-order=purl
|
|
|
|
:: revoke: certificate revocation url (revokeCert)
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-11 20:28:29 +03:00
|
|
|
revoke=purl
|
|
|
|
:: rekey: account key revocation url (keyChange)
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-11 20:28:29 +03:00
|
|
|
rekey=purl
|
2018-06-23 06:43:41 +03:00
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +acme: complete app state
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-14 20:49:27 +03:00
|
|
|
+$ acme
|
2018-11-03 08:01:43 +03:00
|
|
|
$: :: dir: ACME service directory
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
dir=directory
|
2018-11-01 09:54:30 +03:00
|
|
|
:: act: ACME service account
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
act=acct
|
2018-11-01 09:54:30 +03:00
|
|
|
:: liv: active, live configuration
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
liv=(unit config)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: hit: ACME account history
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
hit=history
|
2018-11-01 09:54:30 +03:00
|
|
|
:: nonces: list of unused nonces
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
nonces=(list @t)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: rod: active, in-progress order
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
rod=(unit order)
|
2019-01-11 20:18:08 +03:00
|
|
|
:: next-order: queued domains for validation
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-01-14 23:56:44 +03:00
|
|
|
next-order=(unit (map turf [idx=@ud valid=?]))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: cey: certificate key XX move?
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
cey=key:rsa
|
|
|
|
==
|
|
|
|
--
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
|
|
|
:::: acme app
|
|
|
|
::
|
2019-01-15 01:14:22 +03:00
|
|
|
:: directory-base: LetsEncrypt service directory url
|
|
|
|
::
|
|
|
|
=/ directory-base=purl
|
|
|
|
=- (need (de-purl:html -))
|
2019-01-15 05:26:47 +03:00
|
|
|
'https://acme-v02.api.letsencrypt.org/directory'
|
2018-11-01 09:54:30 +03:00
|
|
|
:: mov: list of outgoing moves for the current transaction
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2018-04-19 09:27:55 +03:00
|
|
|
=| mov=(list move)
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2018-05-15 07:26:59 +03:00
|
|
|
|_ [bow=bowl:gall acme]
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +this: self
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX Should be a +* core alias, see urbit/arvo#712
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ this .
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +emit: emit a move
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
|
|
|
++ emit
|
|
|
|
|= car=card
|
|
|
|
this(mov [[ost.bow car] mov])
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +abet: finalize transaction
|
2018-05-15 23:52:54 +03:00
|
|
|
::
|
2018-04-19 09:27:55 +03:00
|
|
|
++ abet
|
2018-06-23 06:43:41 +03:00
|
|
|
^- (quip move _this)
|
2018-04-19 09:27:55 +03:00
|
|
|
[(flop mov) this(mov ~)]
|
2019-01-14 20:37:51 +03:00
|
|
|
:: +backoff: calculate exponential backoff
|
|
|
|
::
|
|
|
|
++ backoff
|
|
|
|
|= try=@ud
|
|
|
|
^- @dr
|
|
|
|
?: =(0 try) ~s0
|
|
|
|
%+ add
|
|
|
|
(mul ~s1 (bex (dec try)))
|
|
|
|
(mul ~s0..0001 (~(rad og eny.bow) 1.000))
|
2019-01-14 22:56:02 +03:00
|
|
|
:: +acme-wire: create :acme http-request wire
|
|
|
|
::
|
|
|
|
++ acme-wire
|
|
|
|
|= [try=@ud act=@tas =wire]
|
|
|
|
^- ^wire
|
|
|
|
(weld /acme/try/(scot %ud try)/[act] wire)
|
2019-01-14 21:08:46 +03:00
|
|
|
:: +notify: send :hall notification
|
|
|
|
::
|
|
|
|
++ notify
|
|
|
|
|= [=cord =tang]
|
|
|
|
^- card
|
|
|
|
=/ msg=speech:hall
|
|
|
|
:+ %app dap.bow
|
|
|
|
=/ line [%lin & cord]
|
|
|
|
?~(tang line [%fat [%tank tang] line])
|
|
|
|
=/ act
|
|
|
|
[%phrase (sy [our.bow %inbox] ~) [msg ~]]
|
|
|
|
[%poke / [our.bow %hall] %hall-action act]
|
2019-01-14 05:48:45 +03:00
|
|
|
:: +request: unauthenticated http request
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-05-17 19:36:29 +03:00
|
|
|
++ request
|
2018-06-23 06:43:41 +03:00
|
|
|
|= [wir=wire req=hiss]
|
2018-05-15 23:52:54 +03:00
|
|
|
^- card
|
2019-07-04 09:45:54 +03:00
|
|
|
[%request wir (hiss-to-request:html req) *outbound-config:iris]
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +signed-request: JWS JSON POST
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ signed-request
|
|
|
|
|= [url=purl non=@t bod=json]
|
|
|
|
^- hiss
|
|
|
|
:^ url %post
|
|
|
|
(my content-type+['application/jose+json' ~] ~)
|
2018-05-15 07:26:59 +03:00
|
|
|
:- ~
|
2018-06-23 06:43:41 +03:00
|
|
|
^- octs
|
|
|
|
=; pro=json
|
|
|
|
(as-octt:mimes:html (en-json:html (sign:jws key.act pro bod)))
|
2018-04-19 09:27:55 +03:00
|
|
|
:- %o %- my :~
|
2018-06-23 06:43:41 +03:00
|
|
|
nonce+s+non
|
|
|
|
url+s+(crip (en-purl:html url))
|
|
|
|
?^ reg.act
|
|
|
|
kid+s+kid.u.reg.act
|
|
|
|
jwk+(pass:en:jwk key.act)
|
2018-04-19 09:27:55 +03:00
|
|
|
==
|
2019-01-13 10:22:07 +03:00
|
|
|
:: +stateful-request: emit signed, nonce'd request
|
|
|
|
::
|
|
|
|
++ stateful-request
|
2019-01-14 22:56:02 +03:00
|
|
|
|= [[try=@ud act=@tas =wire] =purl =json]
|
2019-01-13 10:22:07 +03:00
|
|
|
^+ this
|
|
|
|
?~ nonces
|
2019-01-14 22:56:02 +03:00
|
|
|
(nonce:effect [act wire])
|
2019-01-13 10:22:07 +03:00
|
|
|
%- emit(nonces t.nonces)
|
2019-01-14 22:56:02 +03:00
|
|
|
%+ request (acme-wire try act wire)
|
2019-01-13 10:22:07 +03:00
|
|
|
(signed-request purl i.nonces json)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +bad-nonce: check if an http response is a badNonce error
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ bad-nonce
|
|
|
|
|= rep=httr
|
|
|
|
^- ?
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX always 400?
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
?. =(400 p.rep) |
|
|
|
|
?~ r.rep |
|
|
|
|
=/ jon=(unit json) (de-json:html q.u.r.rep)
|
|
|
|
?~ jon |
|
2018-11-02 08:10:37 +03:00
|
|
|
=('urn:ietf:params:acme:error:badNonce' type:(error:grab u.jon))
|
2019-01-17 08:41:22 +03:00
|
|
|
:: +rate-limited: handle Acme service rate-limits
|
|
|
|
::
|
|
|
|
++ rate-limited
|
|
|
|
|= [try=@ud act=@tas spur=wire bod=(unit octs)]
|
|
|
|
^+ this
|
|
|
|
=/ jon=(unit json)
|
|
|
|
?~(bod ~ (de-json:html q.u.bod))
|
|
|
|
?~ jon
|
|
|
|
:: no details, back way off
|
|
|
|
:: XX specifically based on wire
|
|
|
|
::
|
|
|
|
(retry:effect try act spur (min ~d1 (backoff (add 10 try))))
|
|
|
|
=/ err (error:grab u.jon)
|
|
|
|
?. =('params:acme:error:rateLimited' type.err)
|
|
|
|
:: incorrect 429 status? backoff normally
|
|
|
|
::
|
|
|
|
(retry:effect try act spur (min ~h1 (backoff try)))
|
|
|
|
|
|
|
|
=/ detail (trip detail.err)
|
|
|
|
:: too many certificates for these domains
|
|
|
|
::
|
|
|
|
?: ?=(^ (find "already issued for exact" detail))
|
|
|
|
=. ..this (retry:effect try act spur ~d7)
|
|
|
|
=/ msg=cord
|
|
|
|
%+ rap 3
|
|
|
|
:~ 'rate limit exceeded: '
|
|
|
|
' too many certificates issued for '
|
|
|
|
?~ rod
|
|
|
|
:: XX shouldn't happen
|
|
|
|
::
|
2019-06-25 07:25:35 +03:00
|
|
|
(en-turf:html /network/arvo/(crip +:(scow %p our.bow)))
|
|
|
|
(join-turf ~(tap in dom.u.rod))
|
2019-01-17 08:41:22 +03:00
|
|
|
'. retrying in ~d7.'
|
|
|
|
==
|
|
|
|
(emit (notify msg ~))
|
|
|
|
:: too many certificates for top-level-domain
|
|
|
|
::
|
|
|
|
?: ?=(^ (find "too many certificates already" detail))
|
|
|
|
=. ..this (retry:effect try act spur ~d7)
|
|
|
|
=/ lul=@dr
|
|
|
|
(add ~d7 (mul ~m1 (~(rad og eny.bow) (bex 10))))
|
|
|
|
=/ msg=cord
|
|
|
|
%+ rap 3
|
|
|
|
:~ 'rate limit exceeded: '
|
|
|
|
' too many certificates issued for '
|
|
|
|
:: XX get from detail
|
|
|
|
::
|
2019-06-25 07:25:35 +03:00
|
|
|
(en-turf:html /network/arvo)
|
2019-01-17 08:41:22 +03:00
|
|
|
'. retrying in '
|
|
|
|
(scot %dr lul) '.'
|
|
|
|
==
|
|
|
|
(emit (notify msg ~))
|
|
|
|
:: XX match more rate-limit conditions
|
|
|
|
:: or backoff by wire
|
|
|
|
::
|
|
|
|
:: - "too many registrations for this IP"
|
|
|
|
:: - "too many registrations for this IP range"
|
|
|
|
:: - "too many currently pending authorizations"
|
|
|
|
:: - "too many failed authorizations recently"
|
|
|
|
:: - "too many new orders recently"
|
|
|
|
::
|
|
|
|
(retry:effect try act spur (min ~d1 (backoff (add 10 try))))
|
2019-01-15 01:14:22 +03:00
|
|
|
:: +failure-message: generic http failure message
|
|
|
|
::
|
|
|
|
++ failure-message
|
|
|
|
|= =purl
|
|
|
|
^- cord
|
|
|
|
%+ rap 3
|
|
|
|
:~ 'unable to reach '
|
|
|
|
(crip (en-purl:html purl)) '. '
|
|
|
|
'please confirm your urbit has network connectivity.'
|
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: |effect: send moves to advance
|
2018-05-18 09:05:12 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ effect
|
2019-01-14 22:56:02 +03:00
|
|
|
|_ try-count=(unit @ud)
|
|
|
|
:: +try: this effect attempt number
|
|
|
|
::
|
|
|
|
++ try (fall try-count 1)
|
2019-01-14 20:37:51 +03:00
|
|
|
:: +validate-domain: confirm that a pending domain resolves to us
|
|
|
|
::
|
|
|
|
++ validate-domain
|
|
|
|
|= idx=@ud
|
|
|
|
^+ this
|
|
|
|
~| %validate-domain-effect-fail
|
|
|
|
?. ?=(^ next-order) ~|(%no-next-order !!)
|
|
|
|
=/ pending
|
2019-01-14 23:56:44 +03:00
|
|
|
(skip ~(tap by u.next-order) |=([turf @ud valid=?] valid))
|
2019-01-14 20:37:51 +03:00
|
|
|
?: =(~ pending)
|
|
|
|
new-order:effect
|
2019-01-14 23:56:44 +03:00
|
|
|
=/ next=[=turf idx=@ud valid=?]
|
2019-01-14 20:37:51 +03:00
|
|
|
~| [%no-next-domain idx=idx]
|
2019-01-14 23:56:44 +03:00
|
|
|
(head (skim pending |=([turf idx=@ud ?] =(idx ^idx))))
|
2019-01-14 20:37:51 +03:00
|
|
|
:: XX should confirm that :turf points to us
|
|
|
|
:: confirms that domain exists (and an urbit is on :80)
|
|
|
|
::
|
|
|
|
=/ =purl
|
|
|
|
:- [sec=| por=~ host=[%& turf.next]]
|
|
|
|
[[ext=`~.udon path=/static] query=~]
|
|
|
|
=/ =wire
|
2019-01-14 23:56:44 +03:00
|
|
|
(acme-wire try %validate-domain /idx/(scot %ud idx.next))
|
2019-01-14 20:37:51 +03:00
|
|
|
(emit (request wire purl %get ~ ~))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +directory: get ACME service directory
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ directory
|
|
|
|
^+ this
|
2018-11-03 08:01:43 +03:00
|
|
|
:: XX now in wire?
|
2018-11-01 09:54:30 +03:00
|
|
|
::
|
2019-01-15 01:14:22 +03:00
|
|
|
(emit (request (acme-wire try %directory /) directory-base %get ~ ~))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +nonce: get a new nonce for the next request
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ nonce
|
2019-01-14 22:56:02 +03:00
|
|
|
|= nex=wire
|
2018-06-27 00:53:29 +03:00
|
|
|
~| [%bad-nonce-next nex]
|
2019-01-14 22:56:02 +03:00
|
|
|
?> ?& ?=(^ nex)
|
|
|
|
?=(nonce-next i.nex)
|
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
^+ this
|
2019-01-14 22:56:02 +03:00
|
|
|
:: XX now in wire?
|
2018-11-01 09:54:30 +03:00
|
|
|
::
|
2019-01-14 22:56:02 +03:00
|
|
|
=/ =wire
|
|
|
|
(acme-wire try %nonce [%next nex])
|
|
|
|
(emit (request wire nonce.dir %get ~ ~))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +register: create ACME service account
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2018-11-01 09:54:30 +03:00
|
|
|
:: Note: accepts services ToS.
|
2018-11-02 08:51:25 +03:00
|
|
|
:: XX add rekey mechanism
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ register
|
|
|
|
^+ this
|
2019-01-16 20:03:36 +03:00
|
|
|
?. =(~ reg.act)
|
|
|
|
?: =(~ next-order)
|
|
|
|
this
|
|
|
|
(validate-domain:effect 0)
|
2019-01-13 10:22:07 +03:00
|
|
|
=/ =json [%o (my [['termsOfServiceAgreed' b+&] ~])]
|
|
|
|
:: XX date in wire?
|
|
|
|
::
|
2019-01-14 22:56:02 +03:00
|
|
|
=/ wire-params [try %register /]
|
|
|
|
(stateful-request wire-params register.dir json)
|
2018-11-02 08:51:25 +03:00
|
|
|
:: +renew: renew certificate
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2018-11-02 08:51:25 +03:00
|
|
|
++ renew
|
|
|
|
^+ this
|
|
|
|
~| %renew-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ liv) ~|(%no-live-config !!)
|
2019-01-11 20:18:08 +03:00
|
|
|
=< new-order:effect
|
|
|
|
(queue-next-order & dom.u.liv)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +new-order: create a new certificate order
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ new-order
|
|
|
|
^+ this
|
|
|
|
~| %new-order-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
2019-01-11 20:18:08 +03:00
|
|
|
?. ?=([~ ^] next-order) ~|(%no-domains !!)
|
2019-01-13 10:22:07 +03:00
|
|
|
=/ =json
|
|
|
|
:- %o %- my :~
|
|
|
|
:- %identifiers
|
|
|
|
:- %a
|
|
|
|
%+ turn
|
2019-01-11 20:18:08 +03:00
|
|
|
~(tap in ~(key by `(map turf *)`u.next-order))
|
2019-06-25 07:25:35 +03:00
|
|
|
|=(a=turf [%o (my type+s+'dns' value+s+(en-turf:html a) ~)])
|
2019-01-13 10:22:07 +03:00
|
|
|
==
|
2019-01-14 22:56:02 +03:00
|
|
|
=/ wire-params [try %new-order /(scot %da now.bow)]
|
|
|
|
(stateful-request wire-params new-order.dir json)
|
2018-11-02 10:21:22 +03:00
|
|
|
:: +cancel-order: cancel failed order, set retry timer
|
|
|
|
::
|
|
|
|
++ cancel-order
|
|
|
|
^+ this
|
|
|
|
~| %cancel-order-effect-fail
|
2019-01-14 22:56:02 +03:00
|
|
|
:: ?> ?=(^ rod)
|
2019-01-11 20:18:08 +03:00
|
|
|
:: XX get failure reason
|
2018-11-02 10:21:22 +03:00
|
|
|
::
|
2019-01-15 01:58:18 +03:00
|
|
|
=/ try=@ud ?~(rod 1 try.u.rod)
|
2019-01-15 02:35:32 +03:00
|
|
|
:: backoff faster than usual
|
|
|
|
::
|
2019-01-15 04:34:14 +03:00
|
|
|
=/ lul=@dr (min ~h1 (backoff (add 4 try)))
|
2019-01-15 01:58:18 +03:00
|
|
|
=/ msg=cord
|
|
|
|
(cat 3 'retrying certificate request in ' (scot %dr lul))
|
|
|
|
=. ..this (emit (notify msg ~))
|
|
|
|
=. ..this (retry:effect try %new-order / lul)
|
2019-01-14 22:56:02 +03:00
|
|
|
:: domains might already be validated
|
2018-11-02 10:21:22 +03:00
|
|
|
::
|
2019-01-14 22:56:02 +03:00
|
|
|
=. ..this (queue-next-order & ?>(?=(^ rod) dom.u.rod))
|
|
|
|
cancel-current-order
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +finalize-order: finalize completed order
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ finalize-order
|
|
|
|
^+ this
|
|
|
|
~| %finalize-order-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
?. ?=(~ pending.aut.u.rod) ~|(%pending-authz !!)
|
|
|
|
?. ?=(~ active.aut.u.rod) ~|(%active-authz !!)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX revisit wrt rate limits
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
?> ?=(%wake sas.u.rod)
|
2019-01-13 10:22:07 +03:00
|
|
|
=/ =json
|
|
|
|
[%o (my csr+s+(en-base64url (met 3 csr.u.rod) `@`csr.u.rod) ~)]
|
2019-01-14 22:56:02 +03:00
|
|
|
=/ wire-params [try %finalize-order /(scot %da now.bow)]
|
|
|
|
(stateful-request wire-params fin.u.rod json)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +check-order: check completed order for certificate availability
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ check-order
|
|
|
|
^+ this
|
|
|
|
~| %check-order-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
?. ?=(~ pending.aut.u.rod) ~|(%pending-authz !!)
|
|
|
|
?. ?=(~ active.aut.u.rod) ~|(%active-authz !!)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX revisit wrt rate limits
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
?> ?=(%wake sas.u.rod)
|
2019-01-14 22:56:02 +03:00
|
|
|
=/ =wire
|
|
|
|
(acme-wire try %check-order /(scot %da now.bow))
|
|
|
|
(emit (request wire ego.u.rod %get ~ ~))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +certificate: download PEM-encoded certificate
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ certificate
|
|
|
|
|= url=purl
|
|
|
|
^+ this
|
|
|
|
~| %certificate-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
=/ hed (my accept+['applicate/x-pem-file' ~] ~)
|
2019-01-14 22:56:02 +03:00
|
|
|
=/ =wire
|
|
|
|
(acme-wire try %certificate /(scot %da now.bow))
|
|
|
|
(emit (request wire url %get hed ~))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +install: tell %eyre about our certificate
|
2018-06-28 22:56:20 +03:00
|
|
|
::
|
|
|
|
++ install
|
|
|
|
^+ this
|
|
|
|
~| %install-effect-fail
|
|
|
|
?> ?=(^ liv)
|
2018-07-16 19:28:23 +03:00
|
|
|
=/ key=wain (ring:en:pem:pkcs8 key.u.liv)
|
2018-06-28 22:56:20 +03:00
|
|
|
(emit %rule /install %cert `[key `wain`cer.u.liv])
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +get-authz: get next ACME service domain authorization object
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ get-authz
|
|
|
|
^+ this
|
|
|
|
~| %get-authz-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
?. ?=(^ pending.aut.u.rod) ~|(%no-pending-authz !!)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX revisit wrt rate limits
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
?> ?=(%wake sas.u.rod)
|
2019-01-14 22:56:02 +03:00
|
|
|
=/ =wire
|
|
|
|
(acme-wire try %get-authz /(scot %da now.bow))
|
|
|
|
(emit (request wire i.pending.aut.u.rod %get ~ ~))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX check/finalize-authz ??
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +test-trial: confirm that ACME domain validation challenge is available
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ test-trial
|
|
|
|
^+ this
|
|
|
|
~| %test-trial-effect-fail
|
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
?. ?=(^ active.aut.u.rod) ~|(%no-active-authz !!)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX revisit wrt rate limits
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
?> ?=(%wake sas.u.rod)
|
|
|
|
=* aut u.active.aut.u.rod
|
|
|
|
=/ pat=path /'.well-known'/acme-challenge/[tok.cal.aut]
|
2018-11-01 09:54:30 +03:00
|
|
|
:: note: requires port 80, just as the ACME service will
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
=/ url=purl [[sec=| por=~ hos=[%& dom.aut]] [ext=~ pat] hed=~]
|
2018-11-01 09:54:30 +03:00
|
|
|
:: =/ url=purl [[sec=| por=`8.081 hos=[%& /localhost]] [ext=~ pat] hed=~]
|
|
|
|
:: XX idx in wire?
|
|
|
|
::
|
2019-01-14 22:56:02 +03:00
|
|
|
=/ =wire
|
|
|
|
(acme-wire try %test-trial /(scot %da now.bow))
|
|
|
|
(emit (request wire url %get ~ ~))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +finalize-trial: notify ACME service that challenge is ready
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ finalize-trial
|
|
|
|
^+ this
|
2018-07-17 02:15:15 +03:00
|
|
|
~| %finalize-trial-effect-fail
|
2018-06-23 06:43:41 +03:00
|
|
|
?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
?. ?=(^ active.aut.u.rod) ~|(%no-active-authz !!)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX revisit wrt rate limits
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
?> ?=(%wake sas.u.rod)
|
|
|
|
=* aut u.active.aut.u.rod
|
2018-11-01 09:54:30 +03:00
|
|
|
:: empty object included for signature
|
2019-01-13 10:22:07 +03:00
|
|
|
:: XX include index in wire?
|
2018-11-01 09:54:30 +03:00
|
|
|
::
|
2019-01-14 22:56:02 +03:00
|
|
|
=/ wire-params [try %finalize-trial /(scot %da now.bow)]
|
|
|
|
(stateful-request wire-params ego.cal.aut [%o ~])
|
2018-06-23 06:43:41 +03:00
|
|
|
:: XX delete-trial?
|
|
|
|
::
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +retry: retry effect after timeout
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2018-06-29 03:03:16 +03:00
|
|
|
++ retry
|
2019-01-14 22:56:02 +03:00
|
|
|
|= [try=@ud act=@tas =wire lull=@dr]
|
2019-01-12 10:00:38 +03:00
|
|
|
:: XX validate wire
|
2018-11-01 09:54:30 +03:00
|
|
|
::
|
2019-01-14 22:56:02 +03:00
|
|
|
(emit %wait (acme-wire +(try) act wire) (add now.bow lull))
|
2018-06-23 06:43:41 +03:00
|
|
|
--
|
2018-11-01 09:54:30 +03:00
|
|
|
:: |event: accept event, emit next effect(s)
|
2018-05-15 23:52:54 +03:00
|
|
|
::
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX should these next effects be triggered at call sites instead?
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ event
|
2019-01-14 22:56:02 +03:00
|
|
|
|_ try=@ud
|
2019-01-14 20:37:51 +03:00
|
|
|
:: +validate-domain: accept a pending domain confirmation response
|
|
|
|
::
|
|
|
|
++ validate-domain
|
|
|
|
|= [=wire rep=httr]
|
|
|
|
^+ this
|
2019-01-14 22:56:02 +03:00
|
|
|
?> ?=([%idx @ *] wire)
|
2019-01-14 20:37:51 +03:00
|
|
|
?. ?=(^ next-order)
|
|
|
|
this
|
2019-01-14 22:56:02 +03:00
|
|
|
=/ idx (slav %ud i.t.wire)
|
2019-04-09 23:59:22 +03:00
|
|
|
=/ valid |(=(200 p.rep) =(307 p.rep))
|
2019-01-14 23:56:44 +03:00
|
|
|
=/ item=(list [=turf idx=@ud valid=?])
|
|
|
|
(skim ~(tap by u.next-order) |=([turf idx=@ud ?] =(^idx idx)))
|
2019-01-14 20:37:51 +03:00
|
|
|
?. ?& ?=([^ ~] item)
|
|
|
|
!valid.i.item
|
|
|
|
==
|
|
|
|
this
|
|
|
|
=. u.next-order
|
2019-01-14 23:56:44 +03:00
|
|
|
(~(put by u.next-order) turf.i.item [idx valid])
|
2019-01-14 20:37:51 +03:00
|
|
|
?. valid
|
2019-01-15 01:14:22 +03:00
|
|
|
?: (lth try 10)
|
|
|
|
=/ lul=@dr (min ~h1 (backoff try))
|
|
|
|
(retry:effect try %validate-domain /idx/(scot %ud idx) lul)
|
2019-01-14 20:37:51 +03:00
|
|
|
:: XX remove next-order, cancel pending requests
|
2019-01-15 01:14:22 +03:00
|
|
|
:: XX include suggestion to fix
|
2019-01-14 20:37:51 +03:00
|
|
|
::
|
2019-01-14 21:08:46 +03:00
|
|
|
=/ msg=cord
|
|
|
|
%+ rap 3
|
|
|
|
:~ 'unable to reach ' (scot %p our.bow)
|
2019-06-25 07:25:35 +03:00
|
|
|
' via http at ' (en-turf:html turf.i.item) ':80'
|
2019-01-14 21:08:46 +03:00
|
|
|
==
|
2019-01-15 03:04:27 +03:00
|
|
|
(emit(next-order ~) (notify msg [(sell !>(rep)) ~]))
|
2019-01-14 23:56:44 +03:00
|
|
|
?: ?=(~ (skip ~(val by u.next-order) |=([@ud valid=?] valid)))
|
2019-01-14 20:37:51 +03:00
|
|
|
new-order:effect
|
|
|
|
(validate-domain:effect +(idx))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +directory: accept ACME service directory, trigger registration
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ directory
|
2018-06-23 07:11:22 +03:00
|
|
|
|= [wir=wire rep=httr]
|
2018-06-23 06:43:41 +03:00
|
|
|
^+ this
|
|
|
|
?. =(200 p.rep)
|
2019-01-15 01:14:22 +03:00
|
|
|
?: (lth try 10)
|
|
|
|
(retry:effect try %directory / (min ~m30 (backoff try)))
|
|
|
|
(emit (notify (failure-message directory-base) [(sell !>(rep)) ~]))
|
2018-06-23 06:43:41 +03:00
|
|
|
=. dir (directory:grab (need (de-json:html q:(need r.rep))))
|
|
|
|
?~(reg.act register:effect this)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +nonce: accept new nonce and trigger next effect
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2019-03-14 21:42:14 +03:00
|
|
|
:: Nonce has already been saved in +http-response. The next effect
|
2018-11-01 09:54:30 +03:00
|
|
|
:: is specified in the wire.
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ nonce
|
2019-01-14 22:56:02 +03:00
|
|
|
|= [=wire rep=httr]
|
2018-06-23 06:43:41 +03:00
|
|
|
^+ this
|
2019-01-14 22:56:02 +03:00
|
|
|
~| [%unrecognized-nonce-wire wire]
|
|
|
|
?> &(?=(^ wire) ?=([%next ^] wire))
|
|
|
|
=* nex i.t.wire
|
2018-06-27 00:53:29 +03:00
|
|
|
~| [%unknown-nonce-next nex]
|
|
|
|
?> ?=(nonce-next nex)
|
|
|
|
?. =(204 p.rep)
|
2019-01-15 01:14:22 +03:00
|
|
|
?: (lth try 10)
|
|
|
|
(retry:effect try %nonce t.wire (min ~m30 (backoff try)))
|
|
|
|
(emit (notify (failure-message nonce.dir) [(sell !>(rep)) ~]))
|
2018-06-27 00:53:29 +03:00
|
|
|
?- nex
|
2018-06-23 06:43:41 +03:00
|
|
|
%register register:effect
|
|
|
|
%new-order new-order:effect
|
|
|
|
%finalize-order finalize-order:effect
|
|
|
|
%finalize-trial finalize-trial:effect
|
2018-05-15 07:26:59 +03:00
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +register: accept ACME service registration
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ register
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
2018-11-02 09:22:39 +03:00
|
|
|
?. |(=(200 p.rep) =(201 p.rep))
|
2018-10-31 21:24:19 +03:00
|
|
|
:: XX possible 204?
|
|
|
|
::
|
2019-01-15 01:14:22 +03:00
|
|
|
?: (lth try 10)
|
|
|
|
(retry:effect try %register / (min ~h1 (backoff try)))
|
|
|
|
(emit (notify (failure-message register.dir) [(sell !>(rep)) ~]))
|
2018-05-15 07:26:59 +03:00
|
|
|
=/ loc=@t
|
|
|
|
q:(head (skim q.rep |=((pair @t @t) ?=(%location p))))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX @da once parser is fixed
|
|
|
|
::
|
2019-01-18 08:37:34 +03:00
|
|
|
=/ wen=@t
|
2018-05-18 18:34:55 +03:00
|
|
|
?~ r.rep
|
|
|
|
(scot %da now.bow)
|
2018-11-02 08:10:37 +03:00
|
|
|
=/ bod=acct:body
|
2018-05-18 18:34:55 +03:00
|
|
|
(acct:grab (need (de-json:html q.u.r.rep)))
|
|
|
|
?> ?=(%valid sas.bod)
|
|
|
|
wen.bod
|
2018-06-29 05:52:35 +03:00
|
|
|
=. reg.act `[wen loc]
|
2019-01-14 20:37:51 +03:00
|
|
|
?: =(~ next-order)
|
|
|
|
this
|
|
|
|
(validate-domain:effect 0)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX rekey
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
:: +new-order: order created, begin processing authorizations
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ new-order
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
|
|
|
?. =(201 p.rep)
|
2018-10-31 21:24:19 +03:00
|
|
|
:: XX possible 204?
|
|
|
|
::
|
2019-01-15 01:14:22 +03:00
|
|
|
?: (lth try 10)
|
|
|
|
(retry:effect try %new-order / (min ~h1 (backoff try)))
|
|
|
|
:: XX next steps, retrying in ??
|
2018-10-31 21:24:19 +03:00
|
|
|
::
|
2019-01-15 01:14:22 +03:00
|
|
|
(emit (notify (failure-message register.dir) [(sell !>(rep)) ~]))
|
2019-01-11 20:18:08 +03:00
|
|
|
?> ?=(^ next-order)
|
2018-05-15 23:52:54 +03:00
|
|
|
=/ loc=@t
|
|
|
|
q:(head (skim q.rep |=((pair @t @t) ?=(%location p))))
|
2018-06-23 06:43:41 +03:00
|
|
|
=/ ego=purl (need (de-purl:html loc))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX parse identifiers, confirm equal to pending domains
|
|
|
|
:: XX check status
|
|
|
|
::
|
2018-11-02 08:10:37 +03:00
|
|
|
=/ bod=order:body
|
2018-05-15 07:26:59 +03:00
|
|
|
(order:grab (need (de-json:html q:(need r.rep))))
|
2019-01-11 20:18:08 +03:00
|
|
|
=/ dom=(set turf) ~(key by u.next-order)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX maybe generate key here?
|
|
|
|
::
|
2019-01-11 20:18:08 +03:00
|
|
|
=/ csr=@ux +:(en:der:pkcs10 cey ~(tap in dom))
|
2018-06-23 06:43:41 +03:00
|
|
|
=/ dor=order
|
2019-01-15 01:58:18 +03:00
|
|
|
[dom try=1 sas=%wake exp.bod ego (need fin.bod) cey csr [aut.bod ~ ~]]
|
2019-01-11 20:18:08 +03:00
|
|
|
get-authz:effect(rod `dor, next-order ~)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +finalize-order: order finalized, poll for certificate
|
2018-05-18 09:05:12 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ finalize-order
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
2018-11-02 05:18:05 +03:00
|
|
|
?: =(504 p.rep)
|
2019-01-15 01:14:22 +03:00
|
|
|
:: retry timeouts frequently
|
2018-10-31 21:24:19 +03:00
|
|
|
::
|
2019-01-15 01:14:22 +03:00
|
|
|
(retry:effect try %finalize-order / (min ~m10 (backoff try)))
|
2018-11-02 05:18:05 +03:00
|
|
|
:: check-order regardless of status code
|
2018-11-01 09:54:30 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
check-order:effect
|
2018-11-02 05:18:05 +03:00
|
|
|
:: +check-order: check order status, dispatch appropriately
|
2018-05-15 23:52:54 +03:00
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
++ check-order
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
2019-01-15 01:14:22 +03:00
|
|
|
~| [%strange-check-order wir]
|
|
|
|
?> ?=(^ rod)
|
2018-06-23 06:43:41 +03:00
|
|
|
?. =(200 p.rep)
|
2019-01-15 01:14:22 +03:00
|
|
|
?: (lth try 10)
|
|
|
|
(retry:effect try %check-order / (min ~m10 (backoff try)))
|
|
|
|
:: XX next steps, retrying in, delete order ??
|
2018-10-31 21:24:19 +03:00
|
|
|
::
|
2019-01-15 01:14:22 +03:00
|
|
|
(emit (notify (failure-message ego.u.rod) [(sell !>(rep)) ~]))
|
2018-11-02 08:10:37 +03:00
|
|
|
=/ bod=order:body
|
|
|
|
(order:grab (need (de-json:html q:(need r.rep))))
|
2018-05-15 23:52:54 +03:00
|
|
|
?+ sas.bod
|
2018-06-23 06:43:41 +03:00
|
|
|
~& [%check-order-status-unknown sas.bod]
|
|
|
|
this
|
2018-10-31 01:20:10 +03:00
|
|
|
:: order failed (at any stage)
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
%invalid
|
|
|
|
~& [%check-order-fail %invalid wir rep]
|
2018-11-02 08:37:02 +03:00
|
|
|
:: XX check authz, get the failure reason
|
2018-11-02 05:18:05 +03:00
|
|
|
:: XX possible to retry any reasons?
|
2018-11-01 09:54:30 +03:00
|
|
|
::
|
2019-01-15 01:14:22 +03:00
|
|
|
=< cancel-order:effect
|
|
|
|
(emit (notify 'certificate order failed' [(sell !>(rep)) ~]))
|
2018-10-31 01:20:10 +03:00
|
|
|
:: initial order state
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
%pending
|
|
|
|
check-order:effect
|
2018-10-31 01:20:10 +03:00
|
|
|
:: validations completed
|
|
|
|
::
|
|
|
|
%ready
|
|
|
|
finalize-order:effect
|
|
|
|
:: finalization requested
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
%processing
|
|
|
|
check-order:effect
|
2018-10-31 01:20:10 +03:00
|
|
|
:: certificate issued
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
%valid
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX update order state
|
|
|
|
:: XX =< delete-trial
|
|
|
|
::
|
2018-11-02 08:10:37 +03:00
|
|
|
~| impossible-order+[wir rep bod]
|
|
|
|
(certificate:effect (need cer.bod))
|
2018-05-15 23:52:54 +03:00
|
|
|
==
|
|
|
|
::
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +certificate: accept PEM-encoded certificate
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ certificate
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
2019-01-15 01:14:22 +03:00
|
|
|
~| [%strange-certificate-response wir]
|
|
|
|
?> ?=(^ rod)
|
2018-06-23 06:43:41 +03:00
|
|
|
?. =(200 p.rep)
|
2019-01-15 01:14:22 +03:00
|
|
|
:: will re-attempt certificate download per order status
|
2018-10-31 21:24:19 +03:00
|
|
|
::
|
2019-01-15 01:14:22 +03:00
|
|
|
?: (lth try 10)
|
|
|
|
(retry:effect try %check-order / (min ~m10 (backoff try)))
|
|
|
|
:: XX next steps, retrying in, get url somehow ??
|
|
|
|
::
|
|
|
|
=/ msg=cord
|
|
|
|
%+ rap 3
|
|
|
|
:~ 'unable to download certificate. '
|
|
|
|
'please confirm that your urbit has network connectivity.'
|
|
|
|
==
|
|
|
|
(emit (notify msg [(sell !>(rep)) ~]))
|
2018-06-23 06:43:41 +03:00
|
|
|
=/ cer=wain (to-wain:format q:(need r.rep))
|
|
|
|
=/ fig=config
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX expiration date
|
|
|
|
::
|
2018-06-28 22:56:20 +03:00
|
|
|
[dom.u.rod key.u.rod cer (add now.bow ~d90) ego.u.rod]
|
2018-11-02 08:51:25 +03:00
|
|
|
:: archive live config
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
=? fig.hit ?=(^ liv) [u.liv fig.hit]
|
2019-01-14 21:08:46 +03:00
|
|
|
:: save new live config, clear active order
|
2018-11-07 02:25:07 +03:00
|
|
|
::
|
2019-01-14 21:08:46 +03:00
|
|
|
=> .(liv (some fig), rod ~)
|
|
|
|
?> ?=(^ liv)
|
|
|
|
:: notify :hall
|
|
|
|
::
|
|
|
|
=> =/ msg=cord
|
|
|
|
%+ rap 3
|
|
|
|
:~ 'received https certificate for '
|
2019-06-25 07:25:35 +03:00
|
|
|
(join-turf ~(tap in dom.u.liv))
|
2019-01-14 21:08:46 +03:00
|
|
|
==
|
|
|
|
(emit (notify msg ~))
|
|
|
|
:: set renewal timer, install certificate in %eyre
|
2018-11-01 09:54:30 +03:00
|
|
|
::
|
2019-01-17 22:08:50 +03:00
|
|
|
:: Certificates expire after ~d90. We want time for retries and
|
|
|
|
:: to work around rate limits, so our renewal timer is for ~d60.
|
|
|
|
:: Renewals count towards weekly rate limits, but are allowed to
|
|
|
|
:: continue past rate limits, so fudge the timer towards the end
|
|
|
|
:: of the week nearest ~d60.
|
|
|
|
::
|
2018-11-02 08:51:25 +03:00
|
|
|
=< install:effect
|
2019-01-17 22:08:50 +03:00
|
|
|
=; lul=@dr
|
|
|
|
(retry:effect 0 %renew / lul)
|
|
|
|
%+ add
|
|
|
|
(mul ~m1 (~(rad og eny.bow) (bex 8)))
|
|
|
|
=/ weekday (daws:chrono:userlib (yore now.bow))
|
|
|
|
?: (gth weekday 4)
|
|
|
|
(sub ~d60 (mul ~d1 (sub weekday 4)))
|
|
|
|
(add ~d60 (mul ~d1 (sub 4 weekday)))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +get-authz: accept ACME service authorization object
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ get-authz
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
2019-01-15 01:14:22 +03:00
|
|
|
~| [%strange-authorization wir]
|
2018-06-23 06:43:41 +03:00
|
|
|
?> ?=(^ rod)
|
|
|
|
?> ?=(^ pending.aut.u.rod)
|
2019-01-15 01:14:22 +03:00
|
|
|
?. =(200 p.rep)
|
|
|
|
?: (lth try 10)
|
|
|
|
(retry:effect try %get-authz / (min ~m10 (backoff try)))
|
|
|
|
:: XX next steps, retrying in ??
|
|
|
|
::
|
|
|
|
(emit (notify (failure-message i.pending.aut.u.rod) [(sell !>(rep)) ~]))
|
2018-11-02 08:10:37 +03:00
|
|
|
=/ bod=auth:body
|
2018-06-23 06:43:41 +03:00
|
|
|
(auth:grab (need (de-json:html q:(need r.rep))))
|
|
|
|
=/ cal=trial
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX parse token to verify url-safe base64?
|
|
|
|
::
|
2018-11-02 08:10:37 +03:00
|
|
|
[%http url.cal.bod tok.cal.bod %recv]
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX check that URLs are the same
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
=/ tau=auth [i.pending.aut.u.rod dom.bod cal]
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX get idx from wire instead?
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
=/ idx=@ud +((lent done.aut.u.rod))
|
|
|
|
=/ rod-aut=order-auth
|
|
|
|
%= aut.u.rod
|
|
|
|
pending t.pending.aut.u.rod
|
|
|
|
active `[idx tau]
|
|
|
|
==
|
2019-03-19 00:05:26 +03:00
|
|
|
test-trial:effect(aut.u.rod rod-aut)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX check/finalize-authz ??
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +test-trial: accept response from challenge test
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ test-trial
|
|
|
|
|= [wir=wire rep=httr]
|
2019-01-15 01:14:22 +03:00
|
|
|
~| [%strange-test-trial wir]
|
2018-06-23 06:43:41 +03:00
|
|
|
?> ?=(^ rod)
|
|
|
|
?> ?=(^ active.aut.u.rod)
|
2018-11-01 05:44:48 +03:00
|
|
|
=* aut u.active.aut.u.rod
|
2019-01-15 01:14:22 +03:00
|
|
|
^+ this
|
|
|
|
?. =(200 p.rep)
|
|
|
|
?: (lth try 10)
|
|
|
|
(retry:effect try %test-trial / (min ~m10 (backoff try)))
|
|
|
|
:: XX next steps, check connectivity, etc. ??
|
|
|
|
::
|
2019-01-15 01:58:18 +03:00
|
|
|
=< cancel-order:effect
|
2019-01-15 01:14:22 +03:00
|
|
|
=/ msg=cord
|
|
|
|
%+ rap 3
|
|
|
|
:~ 'unable to retrieve self-hosted domain validation token '
|
2019-06-25 07:25:35 +03:00
|
|
|
'via ' (en-turf:html dom.aut) '. '
|
2019-01-15 01:14:22 +03:00
|
|
|
'please confirm your urbit has network connectivity.'
|
|
|
|
==
|
|
|
|
(emit (notify msg [(sell !>(rep)) ~]))
|
2018-11-01 05:44:48 +03:00
|
|
|
=/ bod
|
|
|
|
%- as-octs:mimes:html
|
|
|
|
(rap 3 [tok.cal.aut '.' (pass:thumb:jwk key.act) ~])
|
|
|
|
?. ?& ?=(^ r.rep)
|
|
|
|
=(bod u.r.rep)
|
|
|
|
==
|
|
|
|
:: XX probably a DNS misconfiguration
|
|
|
|
::
|
2019-01-15 01:14:22 +03:00
|
|
|
=/ =tang
|
|
|
|
:~ ?~(r.rep leaf+"~" (sell !>(u.r.rep)))
|
|
|
|
leaf+"actual:"
|
|
|
|
(sell !>((some bod)))
|
|
|
|
leaf+"expected:"
|
|
|
|
==
|
|
|
|
(emit (notify 'domain validation value is wrong' tang))
|
2018-06-23 06:43:41 +03:00
|
|
|
finalize-trial:effect
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +finalize-trial:
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ finalize-trial
|
|
|
|
|= [wir=wire rep=httr]
|
|
|
|
^+ this
|
2019-01-15 01:14:22 +03:00
|
|
|
~| [%strange-finalize-trial wir]
|
|
|
|
?> ?=(^ rod)
|
|
|
|
?> ?=(^ active.aut.u.rod)
|
|
|
|
=* aut u.active.aut.u.rod
|
2018-06-23 06:43:41 +03:00
|
|
|
?. =(200 p.rep)
|
2018-10-31 21:24:19 +03:00
|
|
|
:: XX possible 204? assume pending?
|
|
|
|
:: XX handle "challenge is not pending"
|
|
|
|
::
|
|
|
|
?: =(504 p.rep)
|
2019-01-15 01:14:22 +03:00
|
|
|
:: retry timeouts frequently
|
2018-10-31 21:24:19 +03:00
|
|
|
::
|
2019-01-15 01:14:22 +03:00
|
|
|
?: (lth try 10)
|
|
|
|
(retry:effect try %finalize-trial / (min ~m10 (backoff try)))
|
|
|
|
:: XX next steps, check connectivity, etc. ??
|
|
|
|
::
|
|
|
|
(emit (notify (failure-message ego.cal.aut) [(sell !>(rep)) ~]))
|
2018-11-02 10:21:22 +03:00
|
|
|
:: XX get challenge, confirm urn:ietf:params:acme:error:connection
|
2018-10-31 21:24:19 +03:00
|
|
|
::
|
2018-11-02 10:21:22 +03:00
|
|
|
:: =/ err=error:body
|
|
|
|
:: (error:grab (need (de-json:html q:(need r.rep))))
|
|
|
|
:: ?: =('urn:ietf:params:acme:error:malformed' status.err)
|
|
|
|
::
|
2019-01-15 01:14:22 +03:00
|
|
|
=< cancel-order:effect
|
|
|
|
=/ msg=cord
|
|
|
|
'unable to finalize domain validation challenge'
|
|
|
|
(emit (notify msg [(sell !>(rep)) ~]))
|
2018-11-02 08:10:37 +03:00
|
|
|
=/ bod=challenge:body
|
2018-06-23 06:43:41 +03:00
|
|
|
(challenge:grab (need (de-json:html q:(need r.rep))))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX check for other possible values in 200 response
|
|
|
|
:: note: may have already been validated
|
|
|
|
::
|
2018-06-24 05:31:20 +03:00
|
|
|
?> ?=(?(%pending %valid) sas.bod)
|
2018-06-23 06:43:41 +03:00
|
|
|
=/ rod-aut=order-auth
|
|
|
|
aut.u.rod(active ~, done [+.aut(sas.cal %pend) done.aut.u.rod])
|
|
|
|
?~ pending.aut.u.rod
|
2018-10-31 01:20:10 +03:00
|
|
|
check-order:effect(aut.u.rod rod-aut)
|
2018-06-23 06:43:41 +03:00
|
|
|
get-authz:effect(aut.u.rod rod-aut)
|
|
|
|
:: XX delete-trial?
|
|
|
|
::
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +retry: retry effect after timeout
|
2018-06-23 06:43:41 +03:00
|
|
|
::
|
|
|
|
++ retry
|
2019-01-14 22:56:02 +03:00
|
|
|
|= =wire
|
2018-06-29 03:03:16 +03:00
|
|
|
^+ this
|
2019-01-14 22:56:02 +03:00
|
|
|
?> ?=([%try @ @tas *] wire)
|
|
|
|
=/ try (slav %ud i.t.wire)
|
|
|
|
=* fec ~(. effect (some +(try)))
|
|
|
|
=* act i.t.t.wire
|
|
|
|
=* spur t.t.t.wire
|
|
|
|
?+ act
|
|
|
|
~&([%unknown-retry act] this)
|
2019-01-14 20:37:51 +03:00
|
|
|
%validate-domain
|
2019-01-14 22:56:02 +03:00
|
|
|
?> ?=([%idx @ ~] spur)
|
|
|
|
(validate-domain:fec (slav %ud i.t.spur))
|
|
|
|
%directory directory:fec
|
2019-01-15 03:51:35 +03:00
|
|
|
%nonce ?> ?=(^ spur)
|
|
|
|
(nonce:fec t.spur)
|
2019-01-14 22:56:02 +03:00
|
|
|
%register register:fec
|
|
|
|
%renew renew:fec
|
|
|
|
%new-order new-order:fec
|
|
|
|
%finalize-order finalize-order:fec
|
|
|
|
%check-order check-order:fec
|
2019-01-15 03:51:35 +03:00
|
|
|
%certificate check-order:fec :: intentional
|
2019-01-14 22:56:02 +03:00
|
|
|
%get-authz get-authz:fec
|
|
|
|
%test-trial test-trial:fec
|
|
|
|
%finalize-trial finalize-trial:fec
|
2018-06-29 03:03:16 +03:00
|
|
|
==
|
2018-06-23 06:43:41 +03:00
|
|
|
--
|
2019-02-20 02:30:36 +03:00
|
|
|
++ http-response
|
2019-07-04 09:45:54 +03:00
|
|
|
|= [=wire response=client-response:iris]
|
2018-06-23 06:43:41 +03:00
|
|
|
^- (quip move _this)
|
2019-03-14 21:42:14 +03:00
|
|
|
:: ignore progress reports
|
2018-11-01 09:54:30 +03:00
|
|
|
::
|
2019-03-14 21:42:14 +03:00
|
|
|
?: ?=(%progress -.response)
|
2019-02-20 02:30:36 +03:00
|
|
|
[~ this]
|
|
|
|
::
|
2019-01-14 22:56:02 +03:00
|
|
|
?> ?=([%acme ^] wire)
|
|
|
|
=< abet
|
2019-03-14 21:42:14 +03:00
|
|
|
::
|
|
|
|
?: ?=(%cancel -.response)
|
|
|
|
(retry:event t.wire)
|
|
|
|
::
|
2019-07-04 09:45:54 +03:00
|
|
|
=/ rep=httr (to-httr:iris +.response)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: add nonce to pool, if present
|
|
|
|
::
|
2018-06-23 06:43:41 +03:00
|
|
|
=/ nonhed (skim q.rep |=((pair @t @t) ?=(%replay-nonce p)))
|
|
|
|
=? nonces ?=(^ nonhed) [q.i.nonhed nonces]
|
2019-01-14 22:56:02 +03:00
|
|
|
::
|
|
|
|
?> ?=([%try @ @tas *] t.wire)
|
|
|
|
=/ try (slav %ud i.t.t.wire)
|
|
|
|
=* ven ~(. event try)
|
|
|
|
=* act i.t.t.t.wire
|
|
|
|
=* spur t.t.t.t.wire
|
2019-01-17 08:41:22 +03:00
|
|
|
:: backoff if rate-limited
|
|
|
|
::
|
|
|
|
?: =(429 p.rep)
|
|
|
|
(rate-limited try act spur r.rep)
|
2019-01-14 22:56:02 +03:00
|
|
|
:: request nonce if expired-invalid
|
|
|
|
::
|
|
|
|
?: (bad-nonce rep)
|
2019-06-06 22:37:11 +03:00
|
|
|
(nonce:effect [act spur])
|
2019-01-14 22:56:02 +03:00
|
|
|
:: XX replace with :hall notification
|
|
|
|
::
|
2019-03-14 21:42:14 +03:00
|
|
|
~| [%http-response-fail wire]
|
2019-01-14 22:56:02 +03:00
|
|
|
%. [spur rep]
|
|
|
|
?+ act
|
|
|
|
~&([%unknown-http-response act] !!)
|
2019-01-14 20:37:51 +03:00
|
|
|
%validate-domain
|
2019-01-14 22:56:02 +03:00
|
|
|
validate-domain:ven
|
|
|
|
%directory directory:ven
|
|
|
|
%nonce nonce:ven
|
|
|
|
%register register:ven
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX rekey
|
|
|
|
::
|
2019-01-14 22:56:02 +03:00
|
|
|
%new-order new-order:ven
|
|
|
|
%finalize-order finalize-order:ven
|
|
|
|
%check-order check-order:ven
|
|
|
|
%certificate certificate:ven
|
|
|
|
%get-authz get-authz:ven
|
2018-11-01 09:54:30 +03:00
|
|
|
:: XX check/finalize-authz ??
|
|
|
|
::
|
2019-01-14 22:56:02 +03:00
|
|
|
%test-trial test-trial:ven
|
|
|
|
%finalize-trial finalize-trial:ven
|
2018-06-23 06:43:41 +03:00
|
|
|
:: XX delete-trial?
|
2018-11-01 09:54:30 +03:00
|
|
|
::
|
2018-04-19 09:27:55 +03:00
|
|
|
==
|
2019-03-19 00:05:26 +03:00
|
|
|
:: +poke-handle-http-request: receive incoming http request
|
|
|
|
::
|
|
|
|
:: Used to serve the domain validation challenge
|
|
|
|
::
|
|
|
|
++ poke-handle-http-request
|
2019-07-04 09:09:44 +03:00
|
|
|
|= =inbound-request:eyre
|
2019-03-19 00:05:26 +03:00
|
|
|
^- (quip move _this)
|
|
|
|
~& [%handle-http +<]
|
|
|
|
=/ url=(unit (pair pork:eyre quay:eyre))
|
|
|
|
%+ rush
|
|
|
|
url.request.inbound-request
|
|
|
|
;~(plug ;~(pose apat:de-purl:html (easy *pork:eyre)) yque:de-purl:html)
|
|
|
|
::
|
|
|
|
?. ?=(^ url)
|
|
|
|
~| [%invalid-url url.request.inbound-request] !!
|
|
|
|
?. ?=([%'.well-known' %acme-challenge @ ~] q.p.u.url)
|
|
|
|
~| [%unknown-url url.request.inbound-request] !!
|
|
|
|
::
|
|
|
|
:: XX these crashes should be restored
|
2019-07-04 02:01:45 +03:00
|
|
|
:: but %eyre doesn't get an error notification from %gall
|
2019-03-19 00:05:26 +03:00
|
|
|
::
|
|
|
|
:: ?. ?=(^ reg.act) ~|(%no-account !!)
|
|
|
|
:: ?. ?=(^ rod) ~|(%no-active-order !!)
|
|
|
|
:: ?. ?=(^ active.aut.u.rod) ~|(%no-active-authz !!)
|
|
|
|
?. ?& ?=(^ reg.act)
|
|
|
|
?=(^ rod)
|
|
|
|
?=(^ active.aut.u.rod)
|
|
|
|
==
|
|
|
|
=/ =move [ost.bow %http-response %start [%500 ~] ~ %.y]
|
|
|
|
[[move ~] this]
|
|
|
|
::
|
|
|
|
=/ challenge i.t.t.q.p.u.url
|
|
|
|
=* aut u.active.aut.u.rod
|
|
|
|
?. =(tok.cal.aut challenge)
|
|
|
|
=/ =move [ost.bow %http-response %start [%404 ~] ~ %.y]
|
|
|
|
[[move ~] this]
|
|
|
|
=/ =move
|
|
|
|
=/ hed ['content-type' '/text/plain']~
|
|
|
|
=/ bod
|
|
|
|
%- some %- as-octs:mimes:html
|
|
|
|
(rap 3 [tok.cal.aut '.' (pass:thumb:jwk key.act) ~])
|
|
|
|
[ost.bow %http-response %start [%200 hed] bod %.y]
|
|
|
|
[[move ~] this]
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +wake: timer wakeup event
|
2018-06-29 03:03:16 +03:00
|
|
|
::
|
|
|
|
++ wake
|
2019-04-13 01:30:31 +03:00
|
|
|
|= [wir=wire error=(unit tang)]
|
2018-06-29 03:03:16 +03:00
|
|
|
^- (quip move _this)
|
2019-04-13 01:48:22 +03:00
|
|
|
?^ error
|
|
|
|
%- (slog u.error)
|
|
|
|
abet
|
2018-06-29 03:03:16 +03:00
|
|
|
?> ?=([%acme *] wir)
|
|
|
|
abet:(retry:event t.wir)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +poke-acme-order: create new order for a set of domains
|
2018-06-28 22:56:20 +03:00
|
|
|
::
|
|
|
|
++ poke-acme-order
|
2018-06-29 05:52:35 +03:00
|
|
|
|= a=(set turf)
|
|
|
|
abet:(add-order a)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +poke-noun: for debugging
|
2018-04-19 09:27:55 +03:00
|
|
|
::
|
2018-05-17 06:08:15 +03:00
|
|
|
++ poke-noun
|
|
|
|
|= a=*
|
|
|
|
^- (quip move _this)
|
2018-06-23 06:43:41 +03:00
|
|
|
=< abet
|
|
|
|
?+ a
|
2019-01-15 03:54:38 +03:00
|
|
|
this
|
|
|
|
::
|
|
|
|
%dbug-account
|
|
|
|
~& registered=reg.act
|
2019-01-16 20:04:15 +03:00
|
|
|
~& [%public (pass:en:pem:pkcs1 key.act)]
|
|
|
|
~? !=(~ sek.key.act)
|
|
|
|
[%private (ring:en:pem:pkcs1 key.act)]
|
2019-01-15 03:54:38 +03:00
|
|
|
this
|
|
|
|
::
|
|
|
|
%dbug-certificate
|
|
|
|
?~ liv ~&(~ this)
|
|
|
|
~& [%key (ring:en:pem:pkcs8 key.u.liv)]
|
|
|
|
~& [%cert `wain`cer.u.liv]
|
2019-01-16 20:04:15 +03:00
|
|
|
~& [%expires exp.u.liv]
|
|
|
|
~& :- %domains
|
2019-06-25 07:25:35 +03:00
|
|
|
(join-turf ~(tap in dom.u.liv))
|
2019-01-16 20:04:15 +03:00
|
|
|
this
|
|
|
|
::
|
|
|
|
%dbug-history
|
|
|
|
~& [%account-history act.hit]
|
|
|
|
~& [%config-history fig.hit]
|
|
|
|
~& [%failed-order-history fal.hit]
|
2019-01-15 03:54:38 +03:00
|
|
|
this
|
2019-04-19 23:57:13 +03:00
|
|
|
::
|
|
|
|
:: install privkey and cert .pem from /=home=/acme, ignores app state
|
2019-04-23 21:14:04 +03:00
|
|
|
::TODO refactor this out of %acme, see also arvo#1151
|
2019-04-19 23:57:13 +03:00
|
|
|
::
|
|
|
|
%install-from-clay
|
|
|
|
=/ bas=path /(scot %p our.bow)/home/(scot %da now.bow)/acme
|
|
|
|
=/ key=wain .^(wain %cx (weld bas /privkey/pem))
|
|
|
|
=/ cer=wain .^(wain %cx (weld bas /cert/pem))
|
|
|
|
(emit %rule /install %cert `[key cer])
|
2019-01-15 03:54:38 +03:00
|
|
|
::
|
|
|
|
%init
|
|
|
|
init
|
|
|
|
::
|
|
|
|
%register
|
|
|
|
register:effect
|
|
|
|
::
|
|
|
|
%poll
|
|
|
|
check-order:effect
|
|
|
|
::
|
|
|
|
%retry
|
|
|
|
(add-order (sy /network/arvo/(crip +:(scow %p our.bow)) ~))
|
2018-05-17 06:08:15 +03:00
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +poke-path: for debugging
|
2018-05-17 06:08:15 +03:00
|
|
|
::
|
|
|
|
++ poke-path
|
2018-06-29 05:52:35 +03:00
|
|
|
|=(a=path abet:(add-order (sy a ~)))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +prep: initialize and adapt state
|
2018-05-17 06:08:15 +03:00
|
|
|
::
|
2018-05-15 07:26:59 +03:00
|
|
|
++ prep
|
|
|
|
|= old=(unit acme)
|
2018-06-23 06:43:41 +03:00
|
|
|
^- (quip move _this)
|
2018-06-29 07:01:45 +03:00
|
|
|
?~ old
|
2019-03-19 00:05:26 +03:00
|
|
|
=/ =move
|
2019-03-19 01:11:08 +03:00
|
|
|
[ost.bow %connect /acme [~ /'.well-known'/acme-challenge] %acme]
|
2019-03-19 00:05:26 +03:00
|
|
|
[[move ~] this]
|
2018-06-29 07:01:45 +03:00
|
|
|
[~ this(+<+ u.old)]
|
2019-03-19 00:05:26 +03:00
|
|
|
:: +bound: response to %connect binding request
|
|
|
|
::
|
|
|
|
++ bound
|
2019-07-04 09:09:44 +03:00
|
|
|
|= [=wire accepted=? =binding:eyre]
|
2019-03-19 00:05:26 +03:00
|
|
|
?: accepted
|
|
|
|
[~ this]
|
|
|
|
:: XX better error message
|
|
|
|
::
|
|
|
|
~& [%acme-http-path-binding-failed +<]
|
|
|
|
[~ this]
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +rekey: create new 2.048 bit RSA key
|
|
|
|
::
|
|
|
|
:: XX do something about this iteration
|
2018-05-15 07:26:59 +03:00
|
|
|
::
|
2018-11-01 09:54:30 +03:00
|
|
|
++ rekey
|
2018-05-18 19:36:39 +03:00
|
|
|
|= eny=@
|
2018-05-15 23:52:54 +03:00
|
|
|
=| i=@
|
|
|
|
|- ^- key:rsa
|
2018-05-18 19:36:39 +03:00
|
|
|
=/ k (new-key:rsa 2.048 eny)
|
2018-05-16 22:38:50 +03:00
|
|
|
=/ m (met 0 n.pub.k)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: ?: =(0 (mod m 8)) k
|
2018-06-23 06:43:41 +03:00
|
|
|
?: =(2.048 m) k
|
2018-05-15 23:52:54 +03:00
|
|
|
~& [%key iter=i width=m]
|
2018-05-18 19:36:39 +03:00
|
|
|
$(i +(i), eny +(eny))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +init: initialize :acme state
|
2018-05-15 23:52:54 +03:00
|
|
|
::
|
2018-11-03 08:01:43 +03:00
|
|
|
:: We defer the initial request for independence from the causal event,
|
|
|
|
:: which is necessary to init on the boot event. Which we no longer do,
|
|
|
|
:: but we're preserving the pattern for future flexibility.
|
|
|
|
::
|
2018-05-15 07:26:59 +03:00
|
|
|
++ init
|
2019-01-14 22:56:02 +03:00
|
|
|
=< (retry:effect 0 %directory / `@dr`1)
|
2018-06-23 06:43:41 +03:00
|
|
|
%= this
|
2018-05-18 19:58:55 +03:00
|
|
|
act [(rekey eny.bow) ~]
|
|
|
|
cey (rekey (mix eny.bow (shaz now.bow)))
|
2018-05-18 19:36:39 +03:00
|
|
|
==
|
2019-01-11 20:18:08 +03:00
|
|
|
:: +queue-next-order: enqueue domains for validation
|
|
|
|
::
|
|
|
|
++ queue-next-order
|
|
|
|
|= [valid=? dom=(set turf)]
|
|
|
|
^+ this
|
|
|
|
%= this next-order
|
|
|
|
:- ~
|
|
|
|
%+ roll
|
|
|
|
~(tap in dom)
|
2019-01-14 23:56:44 +03:00
|
|
|
|= [=turf state=(map turf [idx=@ud valid=?])]
|
|
|
|
(~(put by state) turf [~(wyt by state) valid])
|
2019-01-11 20:18:08 +03:00
|
|
|
==
|
|
|
|
:: +cancel-current-order: and archive failure for future autopsy
|
|
|
|
::
|
|
|
|
:: XX we may have pending moves out for this order
|
|
|
|
:: put dates in wires, check against order creation date?
|
|
|
|
:: or re-use order-id?
|
|
|
|
::
|
|
|
|
++ cancel-current-order
|
|
|
|
^+ this
|
|
|
|
?~ rod this
|
|
|
|
%= this
|
|
|
|
rod ~
|
|
|
|
fal.hit [u.rod fal.hit]
|
|
|
|
==
|
2018-11-01 09:54:30 +03:00
|
|
|
:: +add-order: add new certificate order
|
2018-05-17 06:08:15 +03:00
|
|
|
::
|
|
|
|
++ add-order
|
2018-06-29 05:52:35 +03:00
|
|
|
|= dom=(set turf)
|
2018-05-17 06:08:15 +03:00
|
|
|
^+ this
|
2019-01-14 19:25:57 +03:00
|
|
|
?: =(~ dom)
|
|
|
|
~|(%acme-empty-certificate-order !!)
|
2018-06-29 07:01:45 +03:00
|
|
|
?: ?=(?(%earl %pawn) (clan:title our.bow))
|
|
|
|
this
|
2019-01-11 20:18:08 +03:00
|
|
|
=. ..this (queue-next-order | dom)
|
|
|
|
=. ..this cancel-current-order
|
2019-01-14 21:08:46 +03:00
|
|
|
:: notify :hall
|
|
|
|
::
|
|
|
|
=. ..this
|
|
|
|
=/ msg=cord
|
|
|
|
%+ rap 3
|
|
|
|
:~ 'requesting an https certificate for '
|
2019-06-25 07:25:35 +03:00
|
|
|
(join-turf ~(tap in dom))
|
2019-01-14 21:08:46 +03:00
|
|
|
==
|
|
|
|
(emit (notify msg ~))
|
2018-11-01 09:54:30 +03:00
|
|
|
:: if registered, create order
|
2018-06-29 07:01:45 +03:00
|
|
|
::
|
|
|
|
?^ reg.act
|
2019-01-14 20:37:51 +03:00
|
|
|
(validate-domain:effect 0)
|
2018-11-01 09:54:30 +03:00
|
|
|
:: if initialized, defer
|
2018-06-29 07:01:45 +03:00
|
|
|
::
|
|
|
|
?.(=(act *acct) this init)
|
2018-04-19 09:27:55 +03:00
|
|
|
--
|