Re: Question regarding custom contextFactory for twisted.web.client.Agent

Jean-Paul Calderone <[email protected]> Tue, 23 May 2017 08:16:22 -0400
Newsgroups gmane.comp.python.twisted.web
Message-ID <CAEeXt4OShOLHpc47yPYEpwpVePAoCdw+Z2j49+mSKx+_yL1KBA@mail.gmail.com>
--===============0161724173834517455==
Content-Type: multipart/alternative; boundary="001a1140ef8cb61a8c05502ff4f4"

--001a1140ef8cb61a8c05502ff4f4
Content-Type: text/plain; charset="UTF-8"

On Tue, May 23, 2017 at 1:54 AM, Glyph <[email protected]> wrote:

>
> > On May 22, 2017, at 5:38 PM, Jason Litzinger <[email protected]>
> wrote:
> >
> >> Thanks for spotting it - please submit a PR to fix it :)
> > Copy that, was planning on it, though originally the context was in
> > comparison to an existing benchmark.
> >
> > I assume the process/coding policies match submissions for Twisted
> > Proper?  I briefly searched for docs specific to benchmark updates but
> > didn't see anything glaring.
>
> It's a bit less formal, but largely similar.  The main difference is that
> you should just file a Github issue rather than a Trac ticket.
>
> > I'm sure I'll need some guidance as to the best way to do this in a
> > fully isolated environment.  For example, the host cert is somewhat
> > tricky.  The simplest thing would be to serve up a self-signed cert, but
> > I think a realistic benchmark needs to validate a full chain and do
> > hostname verification.  Is a PR discussion the best place for these
> > questions?
>
> You can keep asking questions here.
>
> The benchmark could use the Cryptography x509 layer to do setup for a
> custom CA cert, similar to the way many unit tests in Twisted already do...
>

The cryptography APIs for making certs are pretty straightforward and well
documented.  But if another example helps, here's some code that creates a
self-signed ca cert and a client cert with an intermediate cert in between:


https://github.com/LeastAuthority/txkube/blob/faa0374fcef6d089af39a98310f1bd798eb54b08/src/txkube/test/test_authentication.py#L17-L29

https://github.com/LeastAuthority/txkube/blob/faa0374fcef6d089af39a98310f1bd798eb54b08/src/txkube/test/test_authentication.py#L276-L309

Jean-Paul

--001a1140ef8cb61a8c05502ff4f4
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
ue, May 23, 2017 at 1:54 AM, Glyph <span dir=3D"ltr">&lt;<a href=3D"mailto:=
[email protected]" target=3D"_blank">[email protected]</a>&gt;<=
/span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span cl=
ass=3D"gmail-"><br>
&gt; On May 22, 2017, at 5:38 PM, Jason Litzinger &lt;<a href=3D"mailto:jli=
[email protected]">[email protected]</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; Thanks for spotting it - please submit a PR to fix it :)<br>
&gt; Copy that, was planning on it, though originally the context was in<br=
>
&gt; comparison to an existing benchmark.<br>
&gt;<br>
&gt; I assume the process/coding policies match submissions for Twisted<br>
&gt; Proper?=C2=A0 I briefly searched for docs specific to benchmark update=
s but<br>
&gt; didn&#39;t see anything glaring.<br>
<br>
</span>It&#39;s a bit less formal, but largely similar.=C2=A0 The main diff=
erence is that you should just file a Github issue rather than a Trac ticke=
t.<br>
<span class=3D"gmail-"><br>
&gt; I&#39;m sure I&#39;ll need some guidance as to the best way to do this=
 in a<br>
&gt; fully isolated environment.=C2=A0 For example, the host cert is somewh=
at<br>
&gt; tricky.=C2=A0 The simplest thing would be to serve up a self-signed ce=
rt, but<br>
&gt; I think a realistic benchmark needs to validate a full chain and do<br=
>
&gt; hostname verification.=C2=A0 Is a PR discussion the best place for the=
se<br>
&gt; questions?<br>
<br>
</span>You can keep asking questions here.<br>
<br>
The benchmark could use the Cryptography x509 layer to do setup for a custo=
m CA cert, similar to the way many unit tests in Twisted already do...<br><=
/blockquote><div><br></div><div>The cryptography APIs for making certs are =
pretty straightforward and well documented.=C2=A0 But if another example he=
lps, here&#39;s some code that creates a self-signed ca cert and a client c=
ert with an intermediate cert in between:</div><div><br></div><div>=C2=A0 <=
a href=3D"https://github.com/LeastAuthority/txkube/blob/faa0374fcef6d089af3=
9a98310f1bd798eb54b08/src/txkube/test/test_authentication.py#L17-L29">https=
://github.com/LeastAuthority/txkube/blob/faa0374fcef6d089af39a98310f1bd798e=
b54b08/src/txkube/test/test_authentication.py#L17-L29</a><br></div><div>=C2=
=A0 <a href=3D"https://github.com/LeastAuthority/txkube/blob/faa0374fcef6d0=
89af39a98310f1bd798eb54b08/src/txkube/test/test_authentication.py#L276-L309=
">https://github.com/LeastAuthority/txkube/blob/faa0374fcef6d089af39a98310f=
1bd798eb54b08/src/txkube/test/test_authentication.py#L276-L309</a><br></div=
><div><br></div><div>Jean-Paul</div><div><br></div></div></div></div>

--001a1140ef8cb61a8c05502ff4f4--


--===============0161724173834517455==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVHdpc3RlZC13
ZWIgbWFpbGluZyBsaXN0ClR3aXN0ZWQtd2ViQHR3aXN0ZWRtYXRyaXguY29tCmh0dHA6Ly90d2lz
dGVkbWF0cml4LmNvbS9jZ2ktYmluL21haWxtYW4vbGlzdGluZm8vdHdpc3RlZC13ZWIK

--===============0161724173834517455==--