Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
esp32-http-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
esp32-http-server
Commits
cac5fb0c
Commit
cac5fb0c
authored
May 02, 2018
by
Tiago Medicci
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adicionada cadeia de certificados
parent
711bf969
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
13 deletions
+44
-13
https_server.c
https_server.c
+44
-13
No files found.
https_server.c
View file @
cac5fb0c
...
...
@@ -957,15 +957,25 @@ static void http_server(void *arg)
(
ctx
->
srvcert
)
=
&
srvcert
;
(
ctx
->
pkey
)
=
&
pkey
;
ESP_LOGV
(
TAG
,
"Reading CA certificate......"
);
extern
const
unsigned
char
cacert_pem_start
[]
asm
(
"_binary_cacert_pem_start"
);
extern
const
unsigned
char
cacert_pem_end
[]
asm
(
"_binary_cacert_pem_end"
);
const
unsigned
int
cacert_pem_bytes
=
cacert_pem_end
-
cacert_pem_start
;
ESP_LOGV
(
TAG
,
"Reading Private Key......"
);
extern
const
unsigned
char
prvtkey_pem_start
[]
asm
(
"_binary_prvtkey_pem_start"
);
extern
const
unsigned
char
prvtkey_pem_end
[]
asm
(
"_binary_prvtkey_pem_end"
);
const
unsigned
int
prvtkey_pem_bytes
=
prvtkey_pem_end
-
prvtkey_pem_start
;
ESP_LOGV
(
TAG
,
"Reading Root CA certificate......"
);
extern
const
unsigned
char
rootcacert_pem_start
[]
asm
(
"_binary_rootcacert_pem_start"
);
extern
const
unsigned
char
rootcacert_pem_end
[]
asm
(
"_binary_rootcacert_pem_end"
);
const
unsigned
int
rootcacert_pem_bytes
=
rootcacert_pem_end
-
rootcacert_pem_start
;
ESP_LOGV
(
TAG
,
"Reading Intermediate CA certificate......"
);
extern
const
unsigned
char
intermediatecacert_pem_start
[]
asm
(
"_binary_intermediatecacert_pem_start"
);
extern
const
unsigned
char
intermediatecacert_pem_end
[]
asm
(
"_binary_intermediatecacert_pem_end"
);
const
unsigned
int
intermediatecacert_pem_bytes
=
intermediatecacert_pem_end
-
intermediatecacert_pem_start
;
ESP_LOGV
(
TAG
,
"Reading Server certificate......"
);
extern
const
unsigned
char
servercert_pem_start
[]
asm
(
"_binary_servercert_pem_start"
);
extern
const
unsigned
char
servercert_pem_end
[]
asm
(
"_binary_servercert_pem_end"
);
const
unsigned
int
servercert_pem_bytes
=
servercert_pem_end
-
servercert_pem_start
;
ESP_LOGV
(
TAG
,
"Reading Server Private Key......"
);
extern
const
unsigned
char
serverprvtkey_pem_start
[]
asm
(
"_binary_serverprvtkey_pem_start"
);
extern
const
unsigned
char
serverprvtkey_pem_end
[]
asm
(
"_binary_serverprvtkey_pem_end"
);
const
unsigned
int
serverprvtkey_pem_bytes
=
serverprvtkey_pem_end
-
serverprvtkey_pem_start
;
ESP_LOGV
(
TAG
,
"Setting mbedTLS context......"
);
mbedtls_net_init
(
ctx
->
listen_fd
);
...
...
@@ -998,8 +1008,18 @@ static void http_server(void *arg)
*/
ESP_LOGV
(
TAG
,
"SSL server context set own certification......"
);
ESP_LOGV
(
TAG
,
"Parsing test srv_crt......"
);
ret
=
mbedtls_x509_crt_parse
(
ctx
->
srvcert
,
(
const
unsigned
char
*
)
cacert_pem_start
,
cacert_pem_bytes
);
ret
=
mbedtls_x509_crt_parse
(
ctx
->
srvcert
,
(
const
unsigned
char
*
)
servercert_pem_start
,
servercert_pem_bytes
);
if
(
ret
!=
ERR_OK
)
{
ESP_LOGE
(
TAG
,
"ERROR: mbedtls_x509_crt_parse returned %d"
,
ret
);
goto
exit
;
}
ESP_LOGV
(
TAG
,
"OK"
);
ESP_LOGV
(
TAG
,
"Parsing Intermediate CA crt......"
);
ret
=
mbedtls_x509_crt_parse
(
ctx
->
srvcert
,
(
const
unsigned
char
*
)
intermediatecacert_pem_start
,
intermediatecacert_pem_bytes
);
if
(
ret
!=
ERR_OK
)
{
ESP_LOGE
(
TAG
,
"ERROR: mbedtls_x509_crt_parse returned %d"
,
ret
);
...
...
@@ -1007,9 +1027,20 @@ static void http_server(void *arg)
}
ESP_LOGV
(
TAG
,
"OK"
);
ESP_LOGV
(
TAG
,
"Parsing Root CA crt......"
);
ret
=
mbedtls_x509_crt_parse
(
ctx
->
srvcert
,
(
const
unsigned
char
*
)
rootcacert_pem_start
,
rootcacert_pem_bytes
);
if
(
ret
!=
ERR_OK
)
{
ESP_LOGE
(
TAG
,
"ERROR: mbedtls_x509_crt_parse returned %d"
,
ret
);
goto
exit
;
}
ESP_LOGV
(
TAG
,
"OK"
);
ESP_LOGV
(
TAG
,
"SSL server context set private key......"
);
ret
=
mbedtls_pk_parse_key
(
ctx
->
pkey
,
(
const
unsigned
char
*
)
prvtkey_pem_start
,
prvtkey_pem_bytes
,
NULL
,
0
);
ret
=
mbedtls_pk_parse_key
(
ctx
->
pkey
,
(
const
unsigned
char
*
)
server
prvtkey_pem_start
,
server
prvtkey_pem_bytes
,
NULL
,
0
);
if
(
ret
!=
ERR_OK
)
{
ESP_LOGE
(
TAG
,
"ERROR: mbedtls_pk_parse_key returned %d"
,
ret
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment