blog-post

SSL समर्थन: HTTPS इंटरफ़ेस

मैनटीकोर 3.1.2 में आपके अनुप्रयोग या अन्य क्लाइंट (कर्ल, ब्राउज़र आदि) और मैनटीकोर खोज डेमन के बीच डेटा एन्क्रिप्शन का समर्थन जोड़ा गया था। यदि आपको अपने स्थानीय नेटवर्क के अंदर डेटा (क्वेरी, प्रतिक्रियाएं) को अवरोधन से बचाने की आवश्यकता है और विशेष रूप से अगर आप इंटरनेट पर मैनटीकोर खोज से कनेक्ट कर रहे हैं, तो इसे सक्षम करना महत्वपूर्ण है। सेटअप करने के लिए प्रमाणपत्रों का उपयोग करने की आवश्यकता होती है। नीचे स्व-हस्ताक्षरित प्रमाणपत्रों के साथ इसे कैसे किया जा सकता है, का एक उदाहरण है, अन्य विकल्प भी हो सकते हैं जैसे एक वास्तविक CA द्वारा हस्ताक्षरित प्रमाणपत्र खरीदना।

इस ट्यूटोरियल में, हम मैनटीकोर खोज के साथ SSL का उपयोग करने का अध्ययन करेंगे।

यदि आप एक इंटरैक्टिव पाठ्यक्रम से गुजरना चाहते हैं, तो यहां जाएं।

प्रमाणपत्र उत्पन्न करने का उदाहरण


CA कुंजी/प्रमाणपत्र और सर्वर कुंजी/प्रमाणपत्र उत्पन्न करने के लिए आप कर सकते हैं:

CA निजी कुंजी उत्पन्न करें:

root@https-5f6dbcf77c-45t2m:/# openssl genrsa 2048 > /var/lib/manticore/data/ca-key.pem
Generating RSA private key, 2048 bit long modulus
...............................+++++
........+++++
e is 65537 (0x010001)

निजी कुंजी से स्व-हस्ताक्षरित CA (रूट) प्रमाणपत्र उत्पन्न करें (यहां हम “CA” को सामान्य नाम के रूप में निर्दिष्ट करते हैं, आप -subj को पूरी तरह से हटा सकते हैं और सभी फ़ील्ड भर सकते हैं):

root@https-5f6dbcf77c-45t2m:/# openssl req -new -x509 -nodes -days 365 -k
key /var/lib/manticore/data/ca-key.pem -out /var/lib/manticore/data/ca-cert.pem -subj '/CN=CA'

प्रमाणपत्र अनुरोध और सर्वर निजी कुंजी उत्पन्न करें (हम सामान्य नाम के रूप में “127.0.0.1” निर्दिष्ट करते हैं क्योंकि हम searchd को 127.0.0.1 पर चलाएंगे, आप -subj को हटा सकते हैं और वास्तविक जीवन में जो चाहें वह निर्दिष्ट कर सकते हैं):

root@https-5f6dbcf77c-45t2m:/# openssl req -newkey rsa:2048 -days 365 -no
odes -keyout /var/lib/manticore/data/server-key.pem -out /var/lib/manticore/data/server-req.pem  -subj '/CN=127.0.0.1'
Generating a RSA private key
..........................................+++++
.................+++++
writing new private key to '/var/lib/manticore/data/server-key.pem'
--

---

अनुरोध, CA कुंजी और रूट प्रमाणपत्र से प्रमाणपत्र उत्पन्न करें:

root@https-5f6dbcf77c-45t2m:/# openssl x509 -req -in /var/lib/manticore/data/server-req.pem -days 365 -CA /var/lib/manticore/data/ca-cert.pem -CA
Akey /var/lib/manticore/data/ca-key.pem -set_serial 01 -out /var/lib/manticore/data/server-cert.pem
Signature ok
subject=CN = 127.0.0.1
Getting CA Private Key

CA प्रमाणपत्र के साथ सर्वर प्रमाणपत्र सत्यापित करें:

root@https-5f6dbcf77c-45t2m:/# openssl verify -CAfile /var/lib/manticore/data/ca-cert.pem /var/lib/manticore/data/server-cert.pem
/var/lib/manticore/data/server-cert.pem: OK

मैनटीकोर खोज के साथ https के माध्यम से कनेक्ट करना


सुनिश्चित करें कि आके मैनटीकोर खोज कॉन्फ़िग में आवश्यक विकल्प शामिल हैं:

root@https-5f6dbcf77c-45t2m:/# cat /var/lib/manticore/data/manticore.conf|egrep "ssl|https"
listen = 9309:https
ssl_ca = /var/lib/manticore/data/ca-cert.pem
ssl_cert = /var/lib/manticore/data/server-cert.pem
ssl_key = /var/lib/manticore/data/server-key.pem

मैनटीकोर खोज डेमन चलाएं:

root@https-5f6dbcf77c-45t2m:/# searchd -c /var/lib/manticore/data/manticore.conf
Manticore 3.1.2 47b6bc2c@190822 release
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
Copyright (c) 2017-2019, Manticore Software LTD (http://manticoresearch.com)

using config file '/var/lib/manticore/data/manticore.conf' (415 chars)...
listening on all interfaces, port=9309
listening on all interfaces, port=9308
precaching index 'rt'
precached 1 indexes in 0.004 sec

सुरक्षित कनेक्शन के काम करने की पुष्टि करें (आपको JSON प्रतिक्रिया दिखनी चाहिए):

root@https-5f6dbcf77c-45t2m:/# curl --cacert /var/lib/manticore/data/ca-cert.pem "https://127.0.0.1:9309/sql" -d "query=select * from rt where match('abc')";
{"took":4,"timed_out":false,"hits":{"total":0,"hits":[]}}

CA प्रमाणपत्र प्रदान किया जाना चाहिए क्योंकि हमने एक स्व-हस्ताक्षरित प्रमाणपत्र का उपयोग किया है। यदि आप उचित CA प्रमाणपत्र निर्दिष्ट नहीं करते हैं तो यह विफल हो जाएगा, उदाहरण के लिए, आइए CA प्रमाणपत्र के बजाय अपना सर्वर प्रमाणपत्र देखें:

root@https-5f6dbcf77c-45t2m:/# curl --cacert /var/lib/manticore/data/server-cert.pem "https://127.0.0.1:9309/sql" -d "query=select * from rt where match('abc')";
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.

आप इसे पूरी तरह से curl -k विकल्प का उपयोग करके भी छोड़ सकते हैं:

root@https-5f6dbcf77c-45t2m:/# curl -k "https://127.0.0.1:9309/sql" -d "q
query=select * from rt where match('abc')"; echo
{"took":0,"timed_out":false,"hits":{"total":0,"hits":[]}}

लेकिन यह कम सुरक्षित है, हालांकि कुछ मामलों में इसका अर्थ हो सकता है।

बस इतना ही। बहुत कठिन नहीं है।

मैंटीकोर सर्च इंस्टॉल करें

मैंटीकोर सर्च इंस्टॉल करें