blob: cb4592b4cacb8794f97232c4357f333c79c482d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
CREATE OR REPLACE FUNCTION lint_tbscertificate(
tbscert bytea
) RETURNS text
AS $$
DECLARE
t_certificate bytea;
t_header text;
t_certType integer;
t_output text := '';
l_linter RECORD;
BEGIN
-- Add ASN.1 packaging and a dummy signature to create a valid X.509
-- certificate that the linters will parse.
t_certificate := tbscert || E'\\x3003060100030100';
t_header := to_hex(length(t_certificate));
IF length(t_header) % 2 > 0 THEN
t_header := '0' || t_header;
END IF;
IF length(t_header) > 2 THEN
t_header := to_hex(128 + (length(t_header) / 2)) || t_header;
END IF;
t_certificate := E'\\x30' || decode(t_header, 'hex') || t_certificate;
RETURN lint_certificate(t_certificate, TRUE);
END;
$$ LANGUAGE plpgsql STRICT;
|