2016-11-18 3 views
0

Elastic SearchインスタンスをSSLで実行しています。自己署名証明書を作成しています。 Rからelasticパッケージに接続するときに問題が発生しました。弾性Rパッケージの自己署名入り証明書を使用してSecured Elastic Searchに接続

$ curl -u $USER:$PASS 'https://localhost:9200/_cat/health?v' 
curl: (60) Peer certificate cannot be authenticated with known CA certificates 
More details here: http://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. 

明らかなように、この問題が原因ではない証明書は次のとおりです、私は以下のエラーを得た

私は弾性Searchインスタンスに接続しようとしたときに、SSLを有効にした後: これは私が進行方法です信頼されています。 1つの方法は、トラストストアに自己署名証明書を追加することですが、どこにあるのかわかりません。他の方法は、-kを追加して証明書検証をスキップすることです。しかし、私はそれを実行したい。 は、したがって、私は以下のようにroot-ca.pemを指定するには、回避策が見つかりました:

$ curl -u $USER:$PASS 'https://localhost:9200/_cat/health?v' --cacert /home/user/root-ca.pem 
epoch  timestamp cluster  status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent 
1479462058 03:40:58 es-cluster yellow   1   1 365 365 0 0  364    0     -     50.1% 

その後、別のSOの質問は、私は以下のようにファイル~/.curlrc作成を支援:その後

$ cat ~/.curlrc 
capath=/home/user/ 

を、私はしませんでした証明書を指定する必要がありました。

$ curl -u $USER:$PASS 'https://localhost:9200/_cat/health?v' 
epoch  timestamp cluster  status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent 
1479462172 03:42:52 es-cluster yellow   1   1 365 365 0 0  364    0     -     50.1% 

すべてうまくまで今、今、私はRから弾性検索に接続しようとしています。私は以下のエラーが発生しています。

> library(elastic) 
> connect(es_base = "https://localhost", es_port = 9200, es_user = USER, es_pwd = PASS) 
Error: 
    Failed to connect to https://127.0.0.1:9200 
    Remember to start Elasticsearch before connecting 

ログレポートunknown_caエラー。 elastic Rパッケージはhttr/curlのどちらかを使って接続を行っているかもしれませんが、証明書の指定方法を理解できませんでした。 私は解決策hereを参照しましたが、RCurlのために働きます。

お勧めします。

バージョン:

  • R:3.3.1
  • R(弾性パッケージ):0.7.8
  • 弾性検索:2.4.1
  • OS:RHEL 6.7
+1

あなたは 'cainfo'カールオプションを探しています。' ssl_verifypeer'と 'ssl_verifyhost'も設定する必要があると思います。 'connect()'の後に、他の関数、e、.g、 'Search(config = list(cainfo =" /home/user/root-ca.pem "、ssl_verifypeer = 0、' ssl_verifyhost = 0) 'を渡します。 – sckott

+0

Thanks @sckott。あなたの提案が助けになりました。 – Sonny

答えて

0

@sckottが提案したように、私はcainfoパラメータを設定しなければなりませんでした。以下 は、私の場合で働いていたものです:

> library(elastic) 
> library(httr) 
> set_config(config(cainfo == "/home/user/root-ca.pem")) 
> connect(es_base = "https://localhost", es_port = 9200, es_user = USER, es_pwd = PASS) 

はあなたにSckottをありがとうございます。

関連する問題