]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/openid/troubleshooting.mdwn
a0b251d614ef14be40574759648762390abc2e12
[ikiwiki.git] / doc / plugins / openid / troubleshooting.mdwn
1 **TL;DR**
2
3 [[!toc levels=3]]
4
5 # An odyssey through lots of things that have to be right before OpenID works
6
7 Having just (at last) made an ikiwiki installation accept my
8 OpenID, I have learned many of the things that may have to be checked
9 when getting the [[plugins/openid]] plugin to work. (These are probably
10 the reasons why [ikiwiki.info](/) itself won't accept my OpenID!)
11
12 Just to describe my OpenID setup a bit (and why it makes a good stress-test
13 for the OpenID plugin :).
14
15 I'm using my personal home page URL as my OpenID. My page lives at
16 a shared-hosting service I have hired. It contains links that delegate
17 my OpenID processing to [indieauth.com](https://indieauth.com).
18
19 IndieAuth, in turn, uses
20 [rel-me authentication](http://microformats.org/wiki/RelMeAuth) to find
21 an [OAuth](http://microformats.org/wiki/OAuth) provider that can authenticate
22 me. (At present, I am using [github](http://github.com) for that, which
23 is an OAuth provider but not an OpenID provider, so the gatewaying provided
24 by IndieAuth solves that problem.) As far as ikiwiki is concerned,
25 IndieAuth is my OpenID provider; the details beyond that are transparent.
26
27 So, what were the various issues I had to sort out before my first successful
28 login with the [[plugins/openid]] plugin?
29
30 ## no_identity_server: Could not determine ID provider from URL.
31
32 This is the message [ikiwiki.info](/) shows as soon as I enter my home URL
33 as an OpenID. It is also the first one I got on my own ikiwiki installation.
34
35 ### various possible causes ...
36
37 There could be lots of causes. Maybe:
38
39 * the offered OpenID is an `https:` URL and there is an issue in checking
40     the certificate, so the page can't be retrieved?
41 * the page can be retrieved, but it isn't well-formed HTML and the library
42     can't parse it for the needed OpenID links?
43 * ...?
44
45 ### make a luckier setting of useragent ?!
46
47 In my case, it was none of the above. It turns out my shared-hosting provider
48 has a rule that refuses requests with `User-Agent: libwww-perl/6.03` (!!).
49 This is the sort of problem that's really hard to anticipate or plan around.
50 I could fix it (_for this case!_) by changing `useragent:` in `ikiwiki.setup`
51 to a different string that my goofy provider lets through.
52
53 __Recommendation:__ set `useragent:` in `ikiwiki.setup` to some
54 unlikely-to-be-blacklisted value. I can't guess what the best
55 unlikely-to-be-blacklisted value is; if there is one, it's probably the
56 next one all the rude bots will be using anyway, and some goofy provider
57 like mine will blacklist it.
58
59 > If your shared hosting provider is going to randomly break functionality,
60 > I would suggest "voting with your wallet" and taking your business to
61 > one that does not.
62 >
63 > In principle we could set the default UA (if `$config{useragent}` is
64 > unspecified) to `IkiWiki/3.20140915`, or `IkiWiki/3.20140915 libwww-perl/6.03`
65 > (which would be the "most correct" option AIUI), or some such.
66 > That might work, or might get randomly blacklisted too, depending on the
67 > whims of shared hosting providers. If you can't trust your provider to
68 > behave helpfully then there isn't much we can do about it.
69 >
70 > Blocking requests according to UA seems fundamentally flawed, since
71 > I'm fairly sure no hosting provider can afford to blacklist UAs that
72 > claim to be, for instance, Firefox or Chrome. I wouldn't want
73 > to patch IkiWiki to claim to be an interactive browser by default,
74 > but malicious script authors will have no such qualms, so I would
75 > argue that your provider's strategy is already doomed... --[[smcv]]
76
77 >> I agree, and I'll ask them to fix it (and probably refer them to this page).
78 >> One reason they still have my business is that their customer service has
79 >> been notably good; I always get a response from a human on the first try,
80 >> and on the first or second try from a human who understands what I'm saying
81 >> and is able to fix it. With a few exceptions over the years. I've dealt with organizations not like that....
82 >>
83 >> But I included the note here because I'm sure if _they're_ doing it, there's
84 >> probably some nonzero number of other hosting providers where it's also
85 >> happening, so a person setting up OpenID and being baffled by this failure
86 >> needs to know to check for it. Also, while the world of user-agent strings
87 >> can't have anything but relatively luckier and unluckier choices, maybe
88 >> `libwww/perl` is an especially unlucky one?
89
90 >>> Yippee! _My_ provider found their offending `mod_security` rule and took it out,
91 >>> so now [ikiwiki.info](/) accepts my OpenID. I'm still not sure it wouldn't be
92 >>> worthwhile to change the useragent default.... -- Chap
93
94
95 ## Error: OpenID failure: naive_verify_failed_network: Could not contact ID provider to verify response.
96
97 Again, this could have various causes. It was helpful to bump the debug level
98 and get some logging, to see:
99
100     500 Can't connect to indieauth.com:443 (Net::SSL from Crypt-SSLeay can't
101     verify hostnames; either install IO::Socket::SSL or turn off verification
102     by setting the PERL_LWP_SSL_VERIFY_HOSTNAME environment variable to 0)
103
104 I don't belong to the camp that solves every verification problem by turning
105 verification off, so this meant finding out how to get verification to be done.
106 It turns out there are two different Perl modules that can be used for SSL:
107
108 * `IO::Socket::SSL` (verifies hostnames)
109 * `Net::SSL` (_does not_ verify hostnames)
110
111 Both were installed on my hosted server. How was Perl deciding which one
112 to use?
113
114 ### set `PERL_NET_HTTPS_SSL_SOCKET_CLASS` appropriately
115
116 It turns out
117 [there's an environment variable](https://rt.cpan.org/Public/Bug/Display.html?id=71599).
118 So just set `PERL_NET_HTTPS_SSL_SOCKET_CLASS` to `IO::Socket::SSL` and the
119 right module gets used, right?
120
121 [Wrong](https://github.com/csirtgadgets/LWPx-ParanoidAgent/commit/fed6f7d7df8619df0754e8883cfad2ac15703a38#diff-2).
122 That change was made to `ParanoidAgent.pm` back in November 2013 because of an
123 unrelated [bug](https://github.com/csirtgadgets/LWPx-ParanoidAgent/issues/4)
124 in `IO::Socket::SSL`. Essentially, _hmm, something goes wrong in
125 `IO::Socket::SSL` when reading certain large documents, so we'll fix it by
126 forcing the use of `Net::SSL` instead (the one that never verifies hostnames!),
127 no matter what the admin has set `PERL_NET_HTTPS_SSL_SOCKET_CLASS` to!_
128
129 ### undo change that broke `PERL_NET_HTTPS_SSL_SOCKET_CLASS`
130
131 Plenty of [comments](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=738493)
132 quickly appeared about how good an idea that wasn't, and it was corrected in
133 June 2014 with [one commit](https://github.com/csirtgadgets/LWPx-ParanoidAgent/commit/a92ed8f45834a6167ff62d3e7330bb066b307a35)
134 to fix the original reading-long-documents issue in `IO::Socket::SSL` and
135 [another commit](https://github.com/csirtgadgets/LWPx-ParanoidAgent/commit/815c691ad5554a219769a90ca5f4001ae22a4019)
136 that reverts the forcing of `Net::SSL` no matter how the environment is set.
137
138 Unfortunately, there isn't a release in CPAN yet that includes those two
139 commits, but they are only a few lines to edit into your own locally-installed
140 module.
141
142 > To be clear, these are patches to [[!cpan LWPx::ParanoidAgent]].
143 > Debian's `liblwpx-paranoidagent-perl (>= 1.10-3)` appears to
144 > have those two patches. --[[smcv]]
145 >
146 > Irrelevant to this ikiwiki instance, perhaps relevant to others:
147 > I've added these patches to [pkgsrc](http://www.pkgsrc.org)'s
148 > [[!pkgsrc www/p5-LWPx-ParanoidAgent]] and they'll be included in the
149 > soon-to-be-cut 2014Q3 branch. --[[schmonz]]
150
151 ## Still naive_verify_failed_network, new improved reason
152
153     500 Can't connect to indieauth.com:443 (SSL connect attempt failed
154     with unknown error error:14090086:SSL
155     routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed)
156
157 Yay, at least it's trying to verify! Now why can't it verify IndieAuth's
158 certificate?
159
160 [Here's why](https://tools.ietf.org/html/rfc6066#section-3). As it turns out,
161 [indieauth.com](https://indieauth.com/) is itself a virtual host on a shared
162 server. If you naively try
163
164     openssl s_client -connect indieauth.com:443
165
166 you get back a certificate for [indieweb.org](https://indieweb.org/)
167 instead, so the hostname won't verify. If you explicitly indicate what server
168 name you're connecting to:
169
170     openssl s_client -connect indieauth.com:443 -servername indieauth.com
171
172 then, magically, the correct certificate comes back.
173
174 ### ensure `OpenSSL`, `Net::SSLeay`, `IO::Socket::SSL` new enough for SNI
175
176 If your `openssl` doesn't recognize the `-servername` option, it is too old
177 to do SNI, and a newer version needs to be built and installed. In fact,
178 even though SNI support was reportedly backported into OpenSSL 0.9.8f, it will
179 not be used by `IO::Socket::SSL` unless it is
180 [1.0 or higher](http://search.cpan.org/~sullr/IO-Socket-SSL-1.998/lib/IO/Socket/SSL.pod#SNI_Support).
181
182 Then a recent `Net::SSLeay` perl module needs to be built and linked against it.
183
184 > I would tend to be somewhat concerned about the update status and security
185 > of a shared hosting platform that is still on an OpenSSL major version from
186 > pre-2010 - it might be fine, because it might be RHEL or some similarly
187 > change-averse distribution backporting security fixes to ye olde branch,
188 > but equally it might be as bad as it seems at first glance.
189 > "Let the buyer beware", I think... --[[smcv]]
190
191 >> As far as I can tell, this particular provider _is_ on Red Hat (EL 5).
192 >> I can't conclusively tell because I'm in what appears to be a CloudLinux container when I'm in,
193 >> and certain parts of the environment (like `rpm`) I can't see. But everything
194 >> I _can_ see is like several RHEL5 boxen I know and love.
195
196
197 ### Local OpenSSL installation will need certs to trust
198
199 Bear in mind that the OpenSSL distribution doesn't come with a collection
200 of trusted issuer certs. If a newer version is built and installed locally
201 (say, on a shared server where the system locations can't be written), it will
202 need to be given a directory of trusted issuer certs, say by linking to the
203 system-provided ones. However, a change to the certificate hash algorithm used
204 for the symlinks in that directory was [reportedly](http://www.cilogon.org/openssl1)
205 made with OpenSSL 1.0.0. So if the system-provided trusted certificate directory
206 was set up for an earlier OpenSSL version, all the certificates in it will be
207 fine but the hash symlinks will be wrong. That can be fixed by linking only the
208 named certificate files from the system directory into the newly-installed one,
209 and then running the new version of `c_rehash` there.
210
211 ## Still certificate verify failed
212
213 Using [SNI](https://tools.ietf.org/html/rfc6066#section-3)-supporting versions
214 of `IO::Socket::SSL`, `Net::SSLeay`, and `OpenSSL` doesn't do any good if an
215 upper layer hasn't passed down the name of the host being connected to so the
216 SSL layer can SNI for it.
217
218 ### ensure that `LWPx::ParanoidAgent` passes server name to SSL layer for SNI
219
220 That was fixed in `LWPx::ParanoidAgent` with
221 [this commit](https://github.com/csirtgadgets/LWPx-ParanoidAgent/commit/df6df19ccdeeb717c709cccb011af35d3713f546),
222 which needs to be backported by hand if it hasn't made it into a CPAN release
223 yet.
224
225 > Also in Debian's `liblwpx-paranoidagent-perl (>= 1.10-3)`, for the record.
226 > --[[smcv]]
227 >
228 > And now in pkgsrc's `www/p5-LWPx-ParanoidAgent`, FWIW. --[[schmonz]]
229
230 Only that still doesn't end the story, because that hand didn't know what
231 [this hand](https://github.com/noxxi/p5-io-socket-ssl/commit/4f83a3cd85458bd2141f0a9f22f787174d51d587#diff-1)
232 was doing. What good is passing the name in
233 `PeerHost` if the SSL code looks in `PeerAddr` first ... and then, if that
234 doesn't match a regex for a hostname, decides you didn't supply one at all,
235 without even looking at `PeerHost`?
236
237 Happily, is is possible to assign a key that _explicitly_ supplies the
238 server name for SNI:
239
240     --- LWPx/Protocol/http_paranoid.pm    2014-09-08 03:33:00.000000000 -0400
241     +++ LWPx/Protocol/http_paranoid.pm    2014-09-08 03:33:27.000000000 -0400
242     @@ -73,6 +73,7 @@
243             close($el);
244              $sock = $self->socket_class->new(PeerAddr => $addr,
245                                               PeerHost => $host,
246     +                                         SSL_hostname => $host,
247                                               PeerPort => $port,
248                                               Proto    => 'tcp',
249                                               Timeout  => $conn_timeout,
250
251 ... not submitted upstream yet, so needs to be applied by hand.
252
253 > I've [reported this to Debian](https://bugs.debian.org/761635)
254 > (which is where ikiwiki.info's supporting packages come from).
255 > Please report it upstream too, if the Debian maintainer doesn't
256 > get there first. --[[smcv]]
257
258 > Applied in pkgsrc. I haven't attempted to conduct before-and-after
259 > test odysseys, but here's hoping your travails save others some
260 > time and effort. --[[schmonz]]
261
262 # Success!!
263
264 And with that, ladies and gents, I got my first successful OpenID login!
265 I'm pretty sure that if the same fixes can be applied to
266 [ikiwiki.info](/) itself, a wider range of OpenID logins (like mine, for
267 example :) will work here too.
268
269 -- Chap