# HG changeset patch # User Kim Alvefur # Date 1400145151 -7200 # Node ID d85695be0441a6adfd8f9572c92975d0d6fe7066 # Parent 8626abe100e290d6ea69c0ae494d809763d5649e Backout 33f132c3f4b7 until 0.10 diff -r 8626abe100e2 -r d85695be0441 mod_s2s_auth_dane/mod_s2s_auth_dane.lua --- a/mod_s2s_auth_dane/mod_s2s_auth_dane.lua Thu May 08 15:43:58 2014 +0200 +++ b/mod_s2s_auth_dane/mod_s2s_auth_dane.lua Thu May 15 11:12:31 2014 +0200 @@ -22,11 +22,11 @@ local set = require"util.set"; local dns_lookup = require"net.adns".lookup; local hashes = require"util.hashes"; +local base64 = require"util.encodings".base64; local idna_to_ascii = require "util.encodings".idna.to_ascii; local idna_to_unicode = require"util.encodings".idna.to_unicode; local nameprep = require"util.encodings".stringprep.nameprep; local cert_verify_identity = require "util.x509".verify_identity; -local pem2der = require"util.x509".pem2der; do local net_dns = require"net.dns"; @@ -36,6 +36,14 @@ end end +local pat = "%-%-%-%-%-BEGIN ([A-Z ]+)%-%-%-%-%-\r?\n".. +"([0-9A-Za-z=+/\r\n]*)\r?\n%-%-%-%-%-END %1%-%-%-%-%-"; +local function pem2der(pem) + local typ, data = pem:match(pat); + if typ and data then + return base64.decode(data), typ; + end +end local use_map = { ["DANE-EE"] = 3; ["DANE-TA"] = 2; ["PKIX-EE"] = 1; ["PKIX-CA"] = 0 } local implemented_uses = set.new { "DANE-EE", "PKIX-EE" };