无法在Kong 0.10.x和数据存​​储postgresql-9.6之间建立SSL / TLS连接

时间:2018-02-12 10:34:02

标签: postgresql ssl lua tls1.2 kong

我正在使用Kong 10.x和数据存​​储postgresql 9.6。 我想在kong和它的数据存储postgresql之间建立ssl连接。 但我得到以下错误:

Postgresql错误:

LOG:  could not accept SSL connection: tlsv1 alert unknown ca

来自kong的错误:

/usr/local/share/lua/5.1/kong/cmd/migrations.lua:34: [postgres error] could not retrieve current migrations: [postgres error] connection refused

以下是我的Kong和Postgresql配置:

孔:

# Kong configuration file
# DATASTORE
database = postgres                
pg_host = 10.0.1.191
pg_port = 5432
pg_user = kong
pg_password = kong
pg_database = kong    
pg_ssl = on    
pg_ssl_verify = on

# DEVELOPMENT & MISCELLANEOUS
lua_ssl_trusted_certificate = /opt/postgres_ssl/postgresql.crt  # Absolute path to the certificate

PostgreSQL的:

的pg_hba.conf:

hostssl all         all    10.0.1.191/32             md5 clientcert=1

的postgresql.conf:

listen_addresses = '10.0.1.191'
ssl_cert_file = 'server.crt'
ssl_key_file = 'server.key'
ssl_ca_file = 'root.crt'

证书生成程序:

openssl genrsa -passout pass:mypass -des3 -out server.key 1024
openssl rsa -passin pass:mypass -in server.key -out server.key
chmod 400 server.key
openssl req -new -key server.key -days 3650 -out server.crt -x509 -subj '/C=IN/ST=Maharastra/L=Mumbai/O=Development/CN=10.0.1.191'
cp server.crt root.crt
openssl genrsa -passout pass:iotadmin -des3 -out postgresql.key 1024
openssl rsa -in postgresql.key -out postgresql.key -passin pass:mypass
openssl req -new -key postgresql.key -days 3650 -out postgresql.csr -subj '/C=IN/ST=Maharastra/L=Mumbai/O=Development/CN=kong'
openssl x509 -req -in postgresql.csr -CA root.crt -CAkey server.key -out postgresql.crt -CAcreateserial

1 个答案:

答案 0 :(得分:0)

错误消息表明Kong并不信任签署数据库证书的CA.这并不会让人感到惊讶,因为它只知道后者,而不知道CA的证书。

尝试使用lua_ssl_trusted_certificate配置条目的根证书,它应该有效:

lua_ssl_trusted_certificate = /path/to/your/root.crt