unixcharles / acme-client

A Ruby client for the letsencrypt's ACME protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Perhaps it's better to use an Array of Hash instead of Hash for HTTP response link headers

sawanoboly opened this issue · comments

Currently, the following implementation parses the Link header and converts it to Hash.

def decode_link_headers
return unless env.response_headers.key?('Link')
link_header = env.response_headers['Link']
links = link_header.split(', ').map { |entry|
_, link, name = *entry.match(LINK_MATCH)
[name, link]
}
Hash[*links.flatten]
end

However, as mentioned in certbot's comment, it is better to take into account that the same rel is used more than once.

https://github.com/certbot/certbot/pull/8080/files#diff-2ddf346e79198cd9bd28a8e8ee691b7bR802-R803

It's not urgent, but if there is a future change in the spec, such as multiple alternate certificates being issued in boulder, we may not be able to follow it.

Good catch.

Looking into it I also found that I'm not properly following the spec and it fail to match entries with a space (; rel= vs ;rel=)