Commit 508816f
committed
Allow formatting of certificates that contain \r
If an idp_cert contains a '\r' it can blow up upon response validation
with `OpenSSL::X509::CertificateError: nested asn1 error` even if the
cert is otherwise valid (or would have been post-formatting).
From the way `OneLogin::RubySaml::Utils.format_cert` is implemented it
would appear that it *is* expected for '\r's to be present since it
tries to strip them appropriately during the formatting below the guard
statement. Unfortunately, the guard statement at the top short circuits
the formatter when certificates contain '\r' since:
```
irb:0> "asldfkj\r".match(/\x0d/)
=> #<MatchData "\r">
```
Removing the `cert.match(/\x0d/)` doesn't actually break any specs but
from the comment it seems that it may have been intended to ensure
that encoded certs (i.e. .der) are not run through the formatter. I've
added a `.der` cert to `tests/certificates` and asserted that it isn't
changed when run through `format_cert` by checking for `ascii_only?`.1 parent 414d144 commit 508816f
File tree
3 files changed
+6
-1
lines changed- lib/onelogin/ruby-saml
- test
- certificates
3 files changed
+6
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
| |||
0 commit comments