Skip to content

Commit

Permalink
Put generated SSL certificate information into PROGMEM, remove unused…
Browse files Browse the repository at this point in the history
… files
  • Loading branch information
mikee47 committed Jun 5, 2024
1 parent 0b1edd2 commit e989341
Show file tree
Hide file tree
Showing 18 changed files with 8 additions and 442 deletions.
6 changes: 2 additions & 4 deletions Sming/Components/ssl/Tools/make_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,5 @@ openssl pkcs12 -export -in x509_1024.pem -inkey key_1024.pem -keypbe PBE-SHA1-RC
cat ca_x509.pem >> x509_device.pem

# set default key/cert for use in the server
xxd -i x509_1024.cer | sed -e \
"s/x509_1024_cer/default_certificate/" > "$SSL_INCLUDE_DIR/cert.h"
xxd -i key_1024 | sed -e \
"s/key_1024/default_private_key/" > "$SSL_INCLUDE_DIR/private_key.h"
xxd -n default_certificate -i x509_1024.cer | sed -e "s/\[\]/\[\] PROGMEM/" > "$SSL_INCLUDE_DIR/cert.h"
xxd -n default_private_key -i key_1024 | sed -e "s/\[\]/\[\] PROGMEM/" > "$SSL_INCLUDE_DIR/private_key.h"
8 changes: 4 additions & 4 deletions Sming/Components/ssl/src/KeyCertPair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@ bool KeyCertPair::assign(const uint8_t* newKey, unsigned newKeyLength, const uin
if(!key.setLength(newKeyLength)) {
return false;
}
memcpy(key.begin(), newKey, newKeyLength);
memcpy_P(key.begin(), newKey, newKeyLength);
}

if(newCertificateLength != 0 && newCertificate != nullptr) {
if(!certificate.setLength(newCertificateLength)) {
return false;
}
memcpy(certificate.begin(), newCertificate, newCertificateLength);
memcpy_P(certificate.begin(), newCertificate, newCertificateLength);
}

return setPassword(newKeyPassword);
}

bool KeyCertPair::setPassword(const char* newKeyPassword)
{
unsigned passwordLength = (newKeyPassword == nullptr) ? 0 : strlen(newKeyPassword);
unsigned passwordLength = (newKeyPassword == nullptr) ? 0 : strlen_P(newKeyPassword);
if(passwordLength == 0) {
keyPassword = nullptr;
return true;
}

keyPassword.setString(newKeyPassword, passwordLength);
keyPassword.setString(flash_string_t(newKeyPassword), passwordLength);
return keyPassword;
}

Expand Down
27 changes: 0 additions & 27 deletions samples/Basic_AWS/include/ssl/cert.h

This file was deleted.

34 changes: 0 additions & 34 deletions samples/Basic_AWS/include/ssl/private_key.h

This file was deleted.

27 changes: 0 additions & 27 deletions samples/Basic_Ssl/include/ssl/cert.h

This file was deleted.

35 changes: 0 additions & 35 deletions samples/Basic_Ssl/include/ssl/private_key.h

This file was deleted.

27 changes: 0 additions & 27 deletions samples/Echo_Ssl/include/ssl/cert.h

This file was deleted.

Loading

0 comments on commit e989341

Please sign in to comment.