FriendsOfSymfony / FOSElasticaBundle

Elasticsearch PHP integration for your Symfony project using Elastica.
http://friendsofsymfony.github.io
MIT License
1.24k stars 795 forks source link

Cannot connect due to certificate issues #1871

Open hidensity opened 2 years ago

hidensity commented 2 years ago

Hello!

I have just set up a single node Elasticsearch instance, that is using a certificate for communication (the default one). On the CLI the cURL commands works totally fine when I specify the certificate and the username/password.

I've also created a second certificate to extract public certificate, private key and .pem file. When using the .pem file with cURL on the CLI I am also able to connect to "https://localhost:9200" and am receiving the basic node's information.

All the files, .crt, .key and .pem are readable for everybody: -rw-rw-r-- 1 root root 3261 Jul 6 19:36 /etc/ssl/certs/elastic-stack-ca.crt -rw-rw-r-- 1 root root 1843 Jul 6 19:36 /etc/ssl/certs/elastic-stack-ca.key -rw-r--r-- 1 root root 4970 Jul 6 19:37 /etc/ssl/certs/elastic-stack-ca.pem

Now I want to run ./bin/console fos:elastica:create from within my Symfony project's folder. And I'm getting: Creating video 19:53:22 ERROR [elastica] Elastica Request Failure ["exception" => Elastica\Exception\Connection\HttpException^ { …},"request" => ["path" => "video","method" => "PUT","data" => ["mappings" => ["properties" => ["title" => ["type" => "text"],"description" => ["type" => "text"],"duration" => ["type" => "int"]],"dynamic_date_formats" => [],"_meta" => ["model" => "VideoPortal\Entity\Video"]]],"query" => [],"contentType" => "application/json","connection" => ["config" => ["url" => "https://localhost:9200/","curl" => [10025 => "/etc/ssl/certs/elastic-stack-ca.pem"],"headers" => []],"username" => "elastic","password" => "mySecretPassword","ssl" => true,"http_error_codes" => [400,403,404],"logger" => "fos_elastica.logger","compression" => false,"retryOnConflict" => 0,"persistent" => true,"enabled" => false]],"retry" => false]

My fos_elastica.yaml file is attached to this posting (renamed to .txt). fos_elastica.txt

Does somebody have an idea what I am missing or doing wrong?

Thanks in advance.

dralobimene commented 1 year ago

Get same error here with same configuration SSL certificate with let's encrypt and certbot. ElasticSearch installed Composer require friendsofsymfony/elastica-bundle config/packages/fos_elastica.yaml: ssl parameter setted to true username: elastic password: XXX

nothing changed to /etc/elasticsearch/elasticsearch.yml

command and console return with APP_ENV=prod to .env.local: $ symfony console fos:elastica:create Creating app {"message":"Error thrown while running command \"fos:elastica:create\". Message: \"Unknown error:52\"","context":{"exception":{"class":"Elastica\Exception\Connection\HttpException","message":"Unknown error:52","code":0,"file":"/var/www/html/SF_projet02_integration_projet_vite_vue/vendor/ruflin/elastica/src/Transport/Http.php:186"},"command":"fos:elastica:create","message":"Unknown error:52"},"level":500,"level_name":"CRITICAL","channel":"console","datetime":"2023-12-02T12:58:24.612209+00:00","extra":{}} 12:58:24 CRITICAL [console] Error thrown while running command "fos:elastica:create". Message: "Unknown error:52" ["exception" => Elastica\Exception\Connection\HttpException^ { …},"command" => "fos:elastica:create","message" => "Unknown error:52"] {"message":"Command \"fos:elastica:create\" exited with code \"1\"","context":{"command":"fos:elastica:create","code":1},"level":100,"level_name":"DEBUG","channel":"console","datetime":"2023-12-02T12:58:24.624739+00:00","extra":{}} In Http.php line 186:
Unknown error:52
fos:elastica:create [--index [INDEX]] [--no-alias]

command and console return with APP_ENV=dev to .env.local: $ symfony console fos:elastica:create Creating app 13:01:41 ERROR [elastica] Elastica Request Failure ["exception" => Elastica\Exception\Connection\HttpException^ { …},"request" => ["path" => "app_dev","method" => "PUT","data" => ["mappings" => ["properties" => ["id" => ["type" => "text"],"title" => ["type" => "text"],"description" => ["type" => "text"],"latitude" => ["type" => "text"],"longitude" => ["type" => "text"],"slug" => ["type" => "text"],"created_at" => ["type" => "text"],"category" => ["type" => "nested","properties" => ["id" => ["type" => "integer"],"name" => ["type" => "text"],"slug" => ["type" => "keyword"],"created_at" => ["type" => "date"]]]],"dynamic_date_formats" => [],"_meta" => ["model" => "App\Entity\Video"]],"settings" => ["number_of_shards" => 1,"number_of_replicas" => 0]],"query" => [],"contentType" => "application/json","connection" => ["config" => ["headers" => [],"curl" => []],"host" => "localhost","port" => "9200","ssl" => true,"username" => "elastic","password" => "XXX","http_error_codes" => [400,403,404],"logger" => "fos_elastica.logger","compression" => false,"retryOnConflict" => 0,"persistent" => true,"enabled" => false]],"retry" => false] In Http.php line 186:
Unknown error:52
fos:elastica:create [--index [INDEX]] [--no-alias]

Anything is missing me? any clues, advices? is it an issue? Thank you for help/answer Regards

PS .env.local variables: ELASTICSEARCH_HOST=localhost ELASTICSEARCH_PORT=9200