File size: 1,197 Bytes
8d0209c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# OpenSSL Certificate for HTTPS

When launching Gradio locally, you may encounter HTTPS-related issues like microphone access being blocked. To resolve this, you can use OpenSSL to configure HTTPS.

## Generate Certificate and Key

Use OpenSSL to generate a self-signed certificate and private key:

```

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365 -nodes

```

This will generate `cert.pem` and `key.pem` in the current directory.

## Launch Gradio with HTTPS

Launch Gradio by specifying the certificate and key: 

```python

demo.launch(

  server_name="0.0.0.0",

  ssl_certfile="/path/to/cert.pem", 

  ssl_keyfile="/path/to/key.pem"

)

```

By providing the SSL certificate and key, Gradio will launch an HTTPS server instead of HTTP.

The benefits of HTTPS include:

- Enabling browser features like microphone access
- Avoiding mixed content issues
- Encrypted communication

In summary, generating a self-signed certificate with OpenSSL and providing it to Gradio enables launching a local HTTPS server, resolving limitations like microphone blocking. This improves the user experience when interacting with the model.