Skip to content

Commit 608b99a

Browse files
committed
reanamed some APIS and add Erase all
1 parent 238469d commit 608b99a

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

examples/SSLCertificateManagement_Example/SSLCertificateManagement_Example.ino

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ void setup() {
6161

6262
Serial.println("You're connected to the network");
6363
Serial.println();
64-
// uncomment this and fill the array in Arduino_secrets if you want tou
65-
// use your roots certificate pay attention this metod call an errase
66-
// for any of the certs stored on the module flash after the first time
67-
// the erase funciotn no longer works after the first run because erase
68-
// only the standard cert used by arduino mrgsm+
64+
65+
// eraseTrustedRooterase from the module all the actual TrustedRoot
66+
// pointed by the GSM object call this API after the set will try to erase
67+
// if rpresent the certificate present in SECRET_GSM_ROOT_CERTS
68+
client.eraseTrustedRoot();
69+
client.setUserRoots(SECRET_GSM_ROOT_CERTS, SECRET_GSM_ROOT_SIZE);
6970

70-
//client.setUserRoots(SECRET_GSM_ROOT_CERTS, SECRET_GSM_ROOT_SIZE);
71-
client.setPrivateCertificate(SECRET_CERT, "MKRGSM01", sizeof(SECRET_CERT));
71+
client.setSignedCertificate(SECRET_CERT, "MKRGSM01", sizeof(SECRET_CERT));
7272
client.setPrivateKey(SECRET_KEY, "MKRGSMKEY01", sizeof(SECRET_KEY));
73-
client.setClientName("MKRGSM01");
74-
client.setKeyName("MKRGSMKEY01");
75-
client.setServerName("Let_s_Encrypt_Authority_X3");
73+
client.useSignedCertificate("MKRGSM01");
74+
client.usePrivateKey("MKRGSMKEY01");
75+
client.setTrustedRoot("Let_s_Encrypt_Authority_X3");
7676
client.setProfileSSL(1);
7777

7878

src/GSMSSLClient.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ int GSMSSLClient::connect(const char* host, uint16_t port)
134134
return connectSSL(host, port);
135135
}
136136

137-
void GSMSSLClient::setPrivateCertificate(const uint8_t* cert, const char* name, size_t size) {
137+
void GSMSSLClient::setSignedCertificate(const uint8_t* cert, const char* name, size_t size) {
138138
MODEM.sendf("AT+USECMNG=0,1,\"%s\",%d", name, size);
139139
MODEM.waitForResponse(1000);
140140

@@ -150,26 +150,29 @@ void GSMSSLClient::setPrivateKey(const uint8_t* key, const char*name, size_t siz
150150
MODEM.waitForResponse(1000);
151151
}
152152

153-
void GSMSSLClient::setServerName(const char* name) {
153+
void GSMSSLClient::setTrustedRoot(const char* name) {
154154
MODEM.sendf("AT+USECPRF=0,3,\"%s\"", name);
155155
MODEM.waitForResponse(100);
156156
}
157157

158-
void GSMSSLClient::setClientName(const char* name) {
158+
void GSMSSLClient::useSignedCertificate(const char* name) {
159159
MODEM.sendf("AT+USECPRF=0,5,\"%s\"", name);
160160
MODEM.waitForResponse(100);
161161
}
162162

163-
void GSMSSLClient::setKeyName(const char* name) {
163+
void GSMSSLClient::usePrivateKey(const char* name) {
164164
MODEM.sendf("AT+USECPRF=0,6,\"%s\"", name);
165165
MODEM.waitForResponse(100);
166166
}
167167

168-
void GSMSSLClient::setUserRoots(const GSMRootCert * userRoots, size_t size) {
169-
for(int i=0; i<14; i++) {
170-
MODEM.sendf("AT+USECPRF=2,0,\"%s\"", rootsName[i].c_str());
171-
MODEM.waitForResponse(100);
168+
void GSMSSLClient::eraseTrustedRoot() {
169+
for(int i=0; i< _sizeRoot; i++) {
170+
MODEM.sendf("AT+USECPRF=2,0,\"%s\"", _gsmRoots[i].name);
171+
MODEM.waitForResponse(100);
172172
}
173+
}
174+
175+
void GSMSSLClient::setUserRoots(const GSMRootCert * userRoots, size_t size) {
173176
_gsmRoots = userRoots;
174177
_sizeRoot = size;
175178
}

src/GSMSSLClient.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ class GSMSSLClient : public GSMClient {
3232

3333
virtual int connect(IPAddress ip, uint16_t port);
3434
virtual int connect(const char* host, uint16_t port);
35-
virtual void setPrivateCertificate(const uint8_t* cert, const char* name, size_t size);
35+
virtual void setSignedCertificate(const uint8_t* cert, const char* name, size_t size);
3636
virtual void setPrivateKey(const uint8_t* key, const char* name, size_t size);
37-
virtual void setClientName(const char* name);
38-
virtual void setKeyName(const char* name);
39-
virtual void setServerName(const char* name);
37+
virtual void useSignedCertificate(const char* name);
38+
virtual void usePrivateKey(const char* name);
39+
virtual void setTrustedRoot(const char* name);
4040
virtual void setUserRoots(const GSMRootCert * userRoots, size_t size);
41+
virtual void eraseTrustedRoot();
4142

4243
private:
4344
static bool _rootCertsLoaded;

0 commit comments

Comments
 (0)