# Flask Integration issues with Self Signed Certificate via Fleet

**URL:** <https://discuss.elastic.co/t/flask-integration-issues-with-self-signed-certificate-via-fleet/359342>\
**Category:** APM\
**Tags:** elastic-stack-monitoring, python\
**Created:** [May 13, 2024, 6:15am UTC](https://discuss.elastic.co/t/flask-integration-issues-with-self-signed-certificate-via-fleet/359342 "2024-05-13T06:15:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yogesh\_AS](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yogesh_as/32/131781_2.png) [@Yogesh\_AS](https://discuss.elastic.co/u/Yogesh_AS)\
**Post date:** [May 13, 2024, 6:15am UTC](https://discuss.elastic.co/t/flask-integration-issues-with-self-signed-certificate-via-fleet/359342/1 "2024-05-13T06:15:48Z")

</div>

Hi Team ,

Advance thanks for helping me out  
andI am trying to monitor the flask application metrices I am getting an error like given below  
Failed to submit message: "Unable to reach APM Server: HTTPSConnectionPool(host='IP', port=8300): Max retries exceeded with url: /intake/v2/events (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE\_VERIFY\_FAILED] certificate verify failed: unable to get local issuer certificate (\_ssl.c:1007)'))) (url: [https://IP:8300/intake/v2/events](https://IP:8300/intake/v2/events))"

The Flask code is

import requests  
app = Flask( **name** )  
app.config['ELASTIC\_APM'] = {  
'SERVICE\_NAME': 'amtfleet',  
'SECRET\_TOKEN': 'hi',  
'SERVER\_URL': '[https://IP:8300](https://IP:8300)',  
'ENVIRONMENT': 'my-environment',  
'LOG\_LEVEL': 'debug',  
'DEBUG': True  
}  
apm = ElasticAPM(app)

Let me know in the code what to add to get it verify the certificate for self-signed certificate I have a fleet-server.crt and key but I am not getting how to add it as trusted certificate.

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [May 13, 2024, 10:37am UTC](https://discuss.elastic.co/t/flask-integration-issues-with-self-signed-certificate-via-fleet/359342/2 "2024-05-13T10:37:13Z")

</div>

Hi @Yogesh_AS,

You look to be right that it's a certificate issue. Have you tried specifying the [SERVER\_CERT option](https://www.elastic.co/guide/en/apm/agent/python/current/configuration.html#config-server-cert)? I see an example snippet in [this GitHub issue](https://github.com/elastic/apm-agent-python/issues/496) which could help.

Let us know if that resolves your issue.

---

<div class="post-metadata">

**Author:** ![Yogesh\_AS](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yogesh_as/32/131781_2.png) [@Yogesh\_AS](https://discuss.elastic.co/u/Yogesh_AS)\
**Post date:** [May 14, 2024, 5:34am UTC](https://discuss.elastic.co/t/flask-integration-issues-with-self-signed-certificate-via-fleet/359342/3 "2024-05-14T05:34:14Z")

</div>

Hi @carly.richmond ,

Thanks for helping me out I have added these parameter.  
its worked.

from elasticapm.contrib.flask import ElasticAPM

app = Flask( **name** )  
app.config['ELASTIC\_APM'] = {  
'SERVICE\_NAME': 'amtf',  
'SECRET\_TOKEN': 'aamt',  
'ELASTIC\_APM\_SERVER\_URL': '[https://10.10.100.59:8200](https://10.10.100.59:8200)',  
'ENVIRONMENT': 'my-environment',  
'INSTRUMENT' : True,  
'VERIFY\_SERVER\_CERT' : True,  
'SERVER\_CERT': '/root/fleet-server.crt',  
'SERVER\_CA\_CERT\_FILE' : '/root/ca.pem',  
'LOG\_LEVEL': 'debug',  
'DEBUG': True  
}  
apm = ElasticAPM(app)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/5/05ee060be50e0068b99dc1255688cde23b3a27e0.png)

I have a doubt that when we install elastic-agent is it possible to get APM & Infra Metrices without installing APM Agent in managed environment.
