-
Notifications
You must be signed in to change notification settings - Fork 3
/
sslutils.sql.in
73 lines (65 loc) · 2.89 KB
/
sslutils.sql.in
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
CREATE OR REPLACE FUNCTION sslutils_version()
RETURNS text
AS 'MODULE_PATHNAME', 'sslutils_version'
LANGUAGE C IMMUTABLE;
COMMENT ON FUNCTION sslutils_version() IS 'Returns the current version of sslutils';
CREATE OR REPLACE FUNCTION openssl_rsa_generate_key(integer)
RETURNS text
AS '$libdir/sslutils', 'openssl_rsa_generate_key'
LANGUAGE C IMMUTABLE STRICT;
COMMENT ON FUNCTION openssl_rsa_generate_key(integer) IS 'Generates the RSA Private Key.
-- Parameter:
-- param1 : Number of bits.';
CREATE OR REPLACE FUNCTION openssl_rsa_key_to_csr(text, text, text, text, text, text, text)
RETURNS text
AS '$libdir/sslutils', 'openssl_rsa_key_to_csr'
LANGUAGE C IMMUTABLE STRICT;
COMMENT ON FUNCTION openssl_rsa_key_to_csr(text, text, text, text, text, text, text) IS 'Generates the Certificate Signing Request (CSR).
-- Parameters:
-- param1 : rsa key
-- param2 : CN or common name e.g. agentN
-- param3 : C or Country
-- param4 : ST or State
-- param5 : L or Location (City)
-- param6 : OU or Organization Unit
-- param7 : email.';
CREATE OR REPLACE FUNCTION openssl_csr_to_crt(text, text, text)
RETURNS text
AS '$libdir/sslutils', 'openssl_csr_to_crt'
LANGUAGE C IMMUTABLE;
COMMENT ON FUNCTION openssl_csr_to_crt(text, text, text) IS 'Generates the CA/self signed certificate.
-- Parameters:
-- param1 : csr or certificate signing request
-- param2 : Path to CA certificate OR NULL If CA self signed certificate is required.
-- param3 : Path to CA private key OR Path to self private key, If param2 is NULL.';
CREATE OR REPLACE FUNCTION openssl_rsa_generate_crl(text, text)
RETURNS text
AS '$libdir/sslutils', 'openssl_rsa_generate_crl'
LANGUAGE C IMMUTABLE;
COMMENT ON FUNCTION openssl_rsa_generate_crl(text, text) IS 'Generates the Certificate Revocation List (CRL).
-- Parameters:
-- param1 : Path to CA certificate.
-- param2 : Path to CA private key.';
CREATE OR REPLACE FUNCTION openssl_is_crt_expire_on(text, timestamptz)
RETURNS integer
AS '$libdir/sslutils', 'openssl_is_crt_expire_on'
LANGUAGE C IMMUTABLE;
COMMENT ON FUNCTION openssl_is_crt_expire_on(text, timestamptz) IS 'Compare certificate expiry on given time.
-- Parameters:
-- param1 : Path to certificate.
-- param2 : time to compare with end date';
CREATE OR REPLACE FUNCTION openssl_revoke_certificate(text, text)
RETURNS text
AS '$libdir/sslutils', 'openssl_revoke_certificate'
LANGUAGE C IMMUTABLE;
COMMENT ON FUNCTION openssl_revoke_certificate(text, text) IS 'Revoke Certificate and add to Certificate Revocation List (CRL).
-- Parameters:
-- param1 : Path to client certificate to be revoked.
-- param2 : CRL file name specified in postgres config file.';
CREATE OR REPLACE FUNCTION openssl_get_crt_expiry_date(text)
RETURNS timestamptz
AS '$libdir/sslutils', 'openssl_get_crt_expiry_date'
LANGUAGE C IMMUTABLE;
COMMENT ON FUNCTION openssl_get_crt_expiry_date(text) IS 'Return the expiry date of the given certificate.
-- Parameters:
-- param1 : Path to certificate.';