Commit 8f3d033dccb00abcdd2d1fa4f37c0f977b2f2517
Committed by
Andrew Shvayka
1 parent
b864680b
Lwm2m: back: start DTLS -one bootstrap 4 security
Showing
13 changed files
with
365 additions
and
399 deletions
... | ... | @@ -34,6 +34,9 @@ |
34 | 34 | |
35 | 35 | <!-- <logger name="org.thingsboard.server.service.subscription" level="TRACE"/>--> |
36 | 36 | <!-- <logger name="org.thingsboard.server.service.telemetry" level="TRACE"/>--> |
37 | +<!-- <logger name="org.eclipse.californium.scandium.DTLSConnector" level="TRACE" />--> | |
38 | +<!-- <logger name="org.eclipse.californium.scandium.dtls.Handshaker" level="DEBUG" />--> | |
39 | + | |
37 | 40 | <logger name="com.microsoft.azure.servicebus.primitives.CoreMessageReceiver" level="OFF" /> |
38 | 41 | |
39 | 42 | <root level="INFO"> |
... | ... | @@ -41,4 +44,4 @@ |
41 | 44 | </root> |
42 | 45 | |
43 | 46 | |
44 | -</configuration> | |
\ No newline at end of file | ||
47 | +</configuration> | ... | ... |
... | ... | @@ -577,7 +577,7 @@ transport: |
577 | 577 | # model_path_file: "${LWM2M_MODEL_PATH_FILE:./common/transport/lwm2m/src/main/resources/models/}" |
578 | 578 | model_path_file: "${LWM2M_MODEL_PATH_FILE:}" |
579 | 579 | recommended_ciphers: "${LWM2M_RECOMMENDED_CIPHERS:false}" |
580 | - recommended_supported_groups: "${LWM2M_RECOMMENDED_SUPPORTED_GROUPS:false}" | |
580 | + recommended_supported_groups: "${LWM2M_RECOMMENDED_SUPPORTED_GROUPS:true}" | |
581 | 581 | request_pool_size: "${LWM2M_REQUEST_POOL_SIZE:100}" |
582 | 582 | request_error_pool_size: "${LWM2M_REQUEST_ERROR_POOL_SIZE:10}" |
583 | 583 | registered_pool_size: "${LWM2M_REGISTERED_POOL_SIZE:10}" |
... | ... | @@ -593,7 +593,7 @@ transport: |
593 | 593 | key_store_path_file: "${KEY_STORE_PATH_FILE:}" |
594 | 594 | key_store_password: "${LWM2M_KEYSTORE_PASSWORD_SERVER:server_ks_password}" |
595 | 595 | root_alias: "${LWM2M_SERVER_ROOT_CA:rootca}" |
596 | - enable_gen_psk_rpk: "${ENABLE_GEN_PSK_RPK:true}" | |
596 | + enable_gen_new_key_psk_rpk: "${ENABLE_GEN_NEW_KEY_PSK_RPK:false}" | |
597 | 597 | server: |
598 | 598 | id: "${LWM2M_SERVER_ID:123}" |
599 | 599 | bind_address: "${LWM2M_BIND_ADDRESS:0.0.0.0}" |
... | ... | @@ -602,11 +602,14 @@ transport: |
602 | 602 | bind_address_security: "${LWM2M_BIND_ADDRESS_SECURITY:0.0.0.0}" |
603 | 603 | bind_port_security: "${LWM2M_BIND_PORT_SECURITY:5686}" |
604 | 604 | # Only for RPK: Public & Private Key. If the keystore file is missing or not working |
605 | -# create_rpk: "${CREATE_RPK:}" | |
606 | - public_x: "${LWM2M_SERVER_PUBLIC_X:405354ea8893471d9296afbc8b020a5c6201b0bb25812a53b849d4480fa5f069}" | |
607 | - public_y: "${LWM2M_SERVER_PUBLIC_Y:30c9237e946a3a1692c1cafaa01a238a077f632c99371348337512363f28212b}" | |
608 | - private_s: "${LWM2M_SERVER_PRIVATE_S:274671fe40ce937b8a6352cf0a418e8a39e4bf0bb9bf74c910db953c20c73802}" | |
609 | - # Only Certificate_x509: | |
605 | + # create_rpk: "${CREATE_RPK:}" | |
606 | +# - Public Key (Hex): [ 3059301306072a8648ce3d020106082a8648ce3d03010703420004b47a14ea87ab31cce28f24df0ae0a4cfcdb845134bcd088f2fac393b4d4843d140ebc1bfd8f5e0ec402fb8308c5c07bc380783276a385f89ef0da0b1a2545c25 ] | |
607 | +# - Private Key (Hex): [ 3041020100301306072a8648ce3d020106082a8648ce3d030107042730250201010420b65b265abfb9e67be12a7699c13123cf081c72c974688fb4faba82be129ef367 ], | |
608 | +# - Elliptic Curve parameters: [ secp256r1 [ NIST P-256, X9.62 prime256v1 ] (1.2.840.10045.3.1.7) ] | |
609 | + public_x: "${LWM2M_SERVER_PUBLIC_X:b47a14ea87ab31cce28f24df0ae0a4cfcdb845134bcd088f2fac393b4d4843d1}" | |
610 | + public_y: "${LWM2M_SERVER_PUBLIC_Y:40ebc1bfd8f5e0ec402fb8308c5c07bc380783276a385f89ef0da0b1a2545c25}" | |
611 | + private_s: "${LWM2M_SERVER_PRIVATE_S:b65b265abfb9e67be12a7699c13123cf081c72c974688fb4faba82be129ef367}" | |
612 | + # Only Certificate_x509: | |
610 | 613 | alias: "${LWM2M_KEYSTORE_ALIAS_SERVER:server}" |
611 | 614 | bootstrap: |
612 | 615 | enable: "${LWM2M_BOOTSTRAP_ENABLED:true}" |
... | ... | @@ -617,10 +620,10 @@ transport: |
617 | 620 | bind_address_security: "${LWM2M_BIND_ADDRESS_BS:0.0.0.0}" |
618 | 621 | bind_port_security: "${LWM2M_BIND_PORT_SEC_BS:5688}" |
619 | 622 | # Only for RPK: Public & Private Key. If the keystore file is missing or not working |
620 | - public_x: "${LWM2M_SERVER_PUBLIC_X_BS:993ef2b698c6a9c0c1d8be78b13a9383c0854c7c7c7a504d289b403794648183}" | |
621 | - public_y: "${LWM2M_SERVER_PUBLIC_Y_BS:267412d5fc4e5ceb2257cb7fd7f76ebdac2fa9aa100afb162e990074cc0bfaa2}" | |
622 | - private_s: "${LWM2M_SERVER_PRIVATE_S_BS:9dbdbb073fc63570693a9aaf1013414e261c571f27e27fc6a8c1c2ad9347875a}" | |
623 | - # Only Certificate_x509: | |
623 | + public_x: "${LWM2M_SERVER_PUBLIC_X_BS:f6e4e77f76296472bd72acfb6b2dd26fd858042f9075b44b45e2ebeb41cae387}" | |
624 | + public_y: "${LWM2M_SERVER_PUBLIC_Y_BS:3e97534c6b833639f71916041b0596ecd616748d81174d19c59ef02bbb21c822}" | |
625 | + private_s: "${LWM2M_SERVER_PRIVATE_S_BS:3e97534c6b833639f71916041b0596ecd616748d81174d19c59ef02bbb21c822}" | |
626 | + # Only Certificate_x509: | |
624 | 627 | alias: "${LWM2M_KEYSTORE_ALIAS_BOOTSTRAP:bootstrap}" |
625 | 628 | # Redis |
626 | 629 | redis_url: "${LWM2M_REDIS_URL:''}" | ... | ... |
... | ... | @@ -52,7 +52,15 @@ import java.security.spec.InvalidParameterSpecException; |
52 | 52 | import java.security.spec.KeySpec; |
53 | 53 | import java.util.Arrays; |
54 | 54 | |
55 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256; | |
56 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM; | |
57 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8; | |
55 | 58 | import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256; |
59 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA; | |
60 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384; | |
61 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM; | |
62 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8; | |
63 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384; | |
56 | 64 | import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256; |
57 | 65 | import static org.thingsboard.server.transport.lwm2m.server.LwM2MTransportHandler.getCoapConfig; |
58 | 66 | |
... | ... | @@ -62,6 +70,7 @@ import static org.thingsboard.server.transport.lwm2m.server.LwM2MTransportHandle |
62 | 70 | public class LwM2MTransportBootstrapServerConfiguration { |
63 | 71 | private PublicKey publicKey; |
64 | 72 | private PrivateKey privateKey; |
73 | + private boolean pskMode = false; | |
65 | 74 | |
66 | 75 | @Autowired |
67 | 76 | private LwM2MTransportContextBootstrap contextBs; |
... | ... | @@ -105,9 +114,24 @@ public class LwM2MTransportBootstrapServerConfiguration { |
105 | 114 | |
106 | 115 | /** Create and Set DTLS Config */ |
107 | 116 | DtlsConnectorConfig.Builder dtlsConfig = new DtlsConnectorConfig.Builder(); |
108 | - dtlsConfig.setRecommendedSupportedGroupsOnly(!this.contextS.getCtxServer().isRecommendedSupportedGroups()); | |
117 | + dtlsConfig.setRecommendedSupportedGroupsOnly(this.contextS.getCtxServer().isRecommendedSupportedGroups()); | |
109 | 118 | dtlsConfig.setRecommendedCipherSuitesOnly(this.contextS.getCtxServer().isRecommendedCiphers()); |
110 | - dtlsConfig.setSupportedCipherSuites(TLS_PSK_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256); | |
119 | + if (this.pskMode) { | |
120 | + dtlsConfig.setSupportedCipherSuites(TLS_PSK_WITH_AES_128_CBC_SHA256); | |
121 | + } | |
122 | + else { | |
123 | +// dtlsConfig.setSupportedCipherSuites(TLS_PSK_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256); | |
124 | + dtlsConfig.setSupportedCipherSuites(TLS_PSK_WITH_AES_128_CBC_SHA256, | |
125 | + TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, | |
126 | + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, | |
127 | + TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8, | |
128 | + TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8, | |
129 | + TLS_ECDHE_ECDSA_WITH_AES_128_CCM, | |
130 | + TLS_ECDHE_ECDSA_WITH_AES_256_CCM, | |
131 | + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, | |
132 | + TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, | |
133 | + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384); | |
134 | + } | |
111 | 135 | |
112 | 136 | /** Set DTLS Config */ |
113 | 137 | builder.setDtlsConfig(dtlsConfig); |
... | ... | @@ -133,14 +157,16 @@ public class LwM2MTransportBootstrapServerConfiguration { |
133 | 157 | /** by default trust all */ |
134 | 158 | builder.setTrustedCertificates(new X509Certificate[0]); |
135 | 159 | } |
136 | - } else if (this.setServerRPK(builder)) { | |
137 | - this.infoParamsServerRPK(); | |
138 | - } else { | |
139 | - /** by default trust all */ | |
140 | - builder.setTrustedCertificates(new X509Certificate[0]); | |
141 | - log.info("Unable to load X509 files for BootStrapServer"); | |
142 | - this.infoParamsServerPSK(); | |
143 | 160 | } |
161 | + } else if (this.setServerRPK(builder)) { | |
162 | + this.infoPramsUri("RPK"); | |
163 | + this.infoParamsBootstrapServerKey(this.publicKey, this.privateKey); | |
164 | + } else { | |
165 | + /** by default trust all */ | |
166 | + builder.setTrustedCertificates(new X509Certificate[0]); | |
167 | + log.info("Unable to load X509 files for BootStrapServer"); | |
168 | + this.pskMode = true; | |
169 | + this.infoPramsUri("PSK"); | |
144 | 170 | } |
145 | 171 | } catch (KeyStoreException ex) { |
146 | 172 | log.error("[{}] Unable to load X509 files server", ex.getMessage()); |
... | ... | @@ -175,15 +201,23 @@ public class LwM2MTransportBootstrapServerConfiguration { |
175 | 201 | |
176 | 202 | private void infoParamsServerX509(X509Certificate certificate, PublicKey publicKey, PrivateKey privateKey) { |
177 | 203 | try { |
178 | - log.info("Bootstrap Server uses X509 : \n X509 Certificate (Hex): [{}] \n Public Key (Hex): [{}] \n Private Key (Hex): [{}]", | |
179 | - Hex.encodeHexString(certificate.getEncoded()), | |
180 | - Hex.encodeHexString(publicKey.getEncoded()), | |
181 | - Hex.encodeHexString(privateKey.getEncoded())); | |
204 | + this.infoPramsUri("X509"); | |
205 | + log.info("\n- X509 Certificate (Hex): [{}]", | |
206 | + Hex.encodeHexString(certificate.getEncoded())); | |
207 | + this.infoParamsBootstrapServerKey(publicKey, privateKey); | |
182 | 208 | } catch (CertificateEncodingException e) { |
183 | 209 | log.error("", e); |
184 | 210 | } |
185 | 211 | } |
186 | 212 | |
213 | + private void infoPramsUri(String mode) { | |
214 | + log.info("Bootstrap Server uses [{}]: serverNoSecureURI : [{}], serverSecureURI : [{}]", | |
215 | + mode, | |
216 | + this.contextBs.getCtxBootStrap().getBootstrapHost() + ":" + this.contextBs.getCtxBootStrap().getBootstrapPortNoSec(), | |
217 | + this.contextBs.getCtxBootStrap().getBootstrapHostSecurity() + ":" + this.contextBs.getCtxBootStrap().getBootstrapPortSecurity()); | |
218 | + } | |
219 | + | |
220 | + | |
187 | 221 | private boolean setServerRPK(LeshanBootstrapServerBuilder builder) { |
188 | 222 | try { |
189 | 223 | this.generateKeyForBootstrapRPK(); |
... | ... | @@ -231,41 +265,31 @@ public class LwM2MTransportBootstrapServerConfiguration { |
231 | 265 | } |
232 | 266 | } |
233 | 267 | |
234 | - private void infoParamsServerRPK() { | |
268 | + private void infoParamsBootstrapServerKey(PublicKey publicKey, PrivateKey privateKey) { | |
235 | 269 | /** Get x coordinate */ |
236 | - byte[] x = ((ECPublicKey) this.publicKey).getW().getAffineX().toByteArray(); | |
270 | + byte[] x = ((ECPublicKey) publicKey).getW().getAffineX().toByteArray(); | |
237 | 271 | if (x[0] == 0) |
238 | 272 | x = Arrays.copyOfRange(x, 1, x.length); |
239 | 273 | |
240 | 274 | /** Get Y coordinate */ |
241 | - byte[] y = ((ECPublicKey) this.publicKey).getW().getAffineY().toByteArray(); | |
275 | + byte[] y = ((ECPublicKey) publicKey).getW().getAffineY().toByteArray(); | |
242 | 276 | if (y[0] == 0) |
243 | 277 | y = Arrays.copyOfRange(y, 1, y.length); |
244 | 278 | |
245 | 279 | /** Get Curves params */ |
246 | - String params = ((ECPublicKey) this.publicKey).getParams().toString(); | |
247 | - String privHex = Hex.encodeHexString(this.privateKey.getEncoded()); | |
248 | - log.info("Server uses RPK -> serverNoSecureURI : [{}], serverSecureURI : [{}], \n" + | |
249 | - "Public Key (Hex): [{}] \n" + | |
250 | - "Private Key (Hex): [{}], \n" + | |
251 | - "- public_x : [{}] \n" + | |
252 | - "- public_y : [{}] \n" + | |
253 | - "- private_s : [{}] \n" + | |
280 | + String params = ((ECPublicKey) publicKey).getParams().toString(); | |
281 | + String privHex = Hex.encodeHexString(privateKey.getEncoded()); | |
282 | + log.info("\n- Public Key (Hex): [{}] \n" + | |
283 | + "- Private Key (Hex): [{}], \n" + | |
284 | + "public_x: \"${LWM2M_SERVER_PUBLIC_X_BS:{}}\" \n" + | |
285 | + "public_y: \"${LWM2M_SERVER_PUBLIC_Y_BS:{}}\" \n" + | |
286 | + "private_s: \"${LWM2M_SERVER_PRIVATE_S_BS:{}}\" \n" + | |
254 | 287 | "- Elliptic Curve parameters : [{}]", |
255 | - this.contextBs.getCtxBootStrap().getBootstrapHost() + ":" + this.contextBs.getCtxBootStrap().getBootstrapPortNoSec(), | |
256 | - this.contextBs.getCtxBootStrap().getBootstrapHostSecurity() + ":" + this.contextBs.getCtxBootStrap().getBootstrapPortSecurity(), | |
257 | - Hex.encodeHexString(this.publicKey.getEncoded()), | |
258 | - Hex.encodeHexString(this.privateKey.getEncoded()), | |
288 | + Hex.encodeHexString(publicKey.getEncoded()), | |
289 | + Hex.encodeHexString(privateKey.getEncoded()), | |
259 | 290 | Hex.encodeHexString(x), |
260 | 291 | Hex.encodeHexString(y), |
261 | 292 | privHex.substring(privHex.length() - 64), |
262 | 293 | params); |
263 | 294 | } |
264 | - | |
265 | - private void infoParamsServerPSK() { | |
266 | - log.info("Server uses PSK -> serverNoSecureURI : [{}], serverSecureURI : [{}]", | |
267 | - this.contextBs.getCtxBootStrap().getBootstrapHost() + ":" + this.contextBs.getCtxBootStrap().getBootstrapPortNoSec(), | |
268 | - this.contextBs.getCtxBootStrap().getBootstrapHostSecurity() + ":" + this.contextBs.getCtxBootStrap().getBootstrapPortSecurity()); | |
269 | - } | |
270 | - | |
271 | 295 | } | ... | ... |
... | ... | @@ -19,7 +19,6 @@ import lombok.extern.slf4j.Slf4j; |
19 | 19 | import org.eclipse.californium.scandium.config.DtlsConnectorConfig; |
20 | 20 | import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder; |
21 | 21 | import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeEncoder; |
22 | -import org.eclipse.leshan.core.node.codec.LwM2mNodeDecoder; | |
23 | 22 | import org.eclipse.leshan.core.util.Hex; |
24 | 23 | import org.eclipse.leshan.server.californium.LeshanServer; |
25 | 24 | import org.eclipse.leshan.server.californium.LeshanServerBuilder; |
... | ... | @@ -54,7 +53,15 @@ import java.security.spec.InvalidParameterSpecException; |
54 | 53 | import java.security.spec.KeySpec; |
55 | 54 | import java.util.Arrays; |
56 | 55 | |
56 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256; | |
57 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM; | |
58 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8; | |
57 | 59 | import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256; |
60 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA; | |
61 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384; | |
62 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM; | |
63 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8; | |
64 | +import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384; | |
58 | 65 | import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256; |
59 | 66 | import static org.thingsboard.server.transport.lwm2m.server.LwM2MTransportHandler.getCoapConfig; |
60 | 67 | |
... | ... | @@ -64,6 +71,7 @@ import static org.thingsboard.server.transport.lwm2m.server.LwM2MTransportHandle |
64 | 71 | public class LwM2MTransportServerConfiguration { |
65 | 72 | private PublicKey publicKey; |
66 | 73 | private PrivateKey privateKey; |
74 | + private boolean pskMode = false; | |
67 | 75 | |
68 | 76 | @Autowired |
69 | 77 | private LwM2MTransportContextServer context; |
... | ... | @@ -81,9 +89,8 @@ public class LwM2MTransportServerConfiguration { |
81 | 89 | LeshanServerBuilder builder = new LeshanServerBuilder(); |
82 | 90 | builder.setLocalAddress(this.context.getCtxServer().getServerHost(), serverPortNoSec); |
83 | 91 | builder.setLocalSecureAddress(this.context.getCtxServer().getServerHostSecurity(), serverSecurePort); |
84 | - builder.setEncoder(new DefaultLwM2mNodeEncoder()); | |
85 | - LwM2mNodeDecoder decoder = new DefaultLwM2mNodeDecoder(); | |
86 | - builder.setDecoder(decoder); | |
92 | + builder.setDecoder(new DefaultLwM2mNodeDecoder()); | |
93 | + /** Use a magic converter to support bad type send by the UI. */ | |
87 | 94 | builder.setEncoder(new DefaultLwM2mNodeEncoder(LwM2mValueConverterImpl.getInstance())); |
88 | 95 | |
89 | 96 | /** Create CoAP Config */ |
... | ... | @@ -102,17 +109,30 @@ public class LwM2MTransportServerConfiguration { |
102 | 109 | |
103 | 110 | /** Create DTLS Config */ |
104 | 111 | DtlsConnectorConfig.Builder dtlsConfig = new DtlsConnectorConfig.Builder(); |
105 | - dtlsConfig.setRecommendedSupportedGroupsOnly(!this.context.getCtxServer().isRecommendedSupportedGroups()); | |
112 | + dtlsConfig.setRecommendedSupportedGroupsOnly(this.context.getCtxServer().isRecommendedSupportedGroups()); | |
106 | 113 | dtlsConfig.setRecommendedCipherSuitesOnly(this.context.getCtxServer().isRecommendedCiphers()); |
107 | - dtlsConfig.setSupportedCipherSuites(TLS_PSK_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256); | |
114 | + if (this.pskMode) { | |
115 | + dtlsConfig.setSupportedCipherSuites(TLS_PSK_WITH_AES_128_CBC_SHA256); | |
116 | + } | |
117 | + else { | |
118 | +// dtlsConfig.setSupportedCipherSuites(TLS_PSK_WITH_AES_128_CBC_SHA256, | |
119 | +// TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256); | |
120 | + dtlsConfig.setSupportedCipherSuites(TLS_PSK_WITH_AES_128_CBC_SHA256, | |
121 | + TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, | |
122 | + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, | |
123 | + TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8, | |
124 | + TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8, | |
125 | + TLS_ECDHE_ECDSA_WITH_AES_128_CCM, | |
126 | + TLS_ECDHE_ECDSA_WITH_AES_256_CCM, | |
127 | + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, | |
128 | + TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, | |
129 | + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384); | |
130 | + } | |
131 | + | |
108 | 132 | |
109 | 133 | /** Set DTLS Config */ |
110 | 134 | builder.setDtlsConfig(dtlsConfig); |
111 | 135 | |
112 | - /** Use a magic converter to support bad type send by the UI. */ | |
113 | - builder.setEncoder(new DefaultLwM2mNodeEncoder(LwM2mValueConverterImpl.getInstance())); | |
114 | - | |
115 | - | |
116 | 136 | /** Create LWM2M server */ |
117 | 137 | return builder.build(); |
118 | 138 | } |
... | ... | @@ -138,14 +158,16 @@ public class LwM2MTransportServerConfiguration { |
138 | 158 | return endpoint.startsWith(expectedX509CommonName); |
139 | 159 | } |
140 | 160 | })); |
141 | - } else if (this.setServerRPK(builder)) { | |
142 | - this.infoParamsServerRPK(); | |
143 | - } else { | |
144 | - /** by default trust all */ | |
145 | - builder.setTrustedCertificates(new X509Certificate[0]); | |
146 | - log.info("Unable to load X509 files for LWM2MServer"); | |
147 | - this.infoParamsServerPSK(); | |
148 | 161 | } |
162 | + } else if (this.setServerRPK(builder)) { | |
163 | + this.infoPramsUri("RPK"); | |
164 | + this.infoParamsServerKey(this.publicKey, this.privateKey); | |
165 | + } else { | |
166 | + /** by default trust all */ | |
167 | + builder.setTrustedCertificates(new X509Certificate[0]); | |
168 | + log.info("Unable to load X509 files for LWM2MServer"); | |
169 | + this.pskMode = true; | |
170 | + this.infoPramsUri("PSK"); | |
149 | 171 | } |
150 | 172 | } catch (KeyStoreException ex) { |
151 | 173 | log.error("[{}] Unable to load X509 files server", ex.getMessage()); |
... | ... | @@ -169,8 +191,7 @@ public class LwM2MTransportServerConfiguration { |
169 | 191 | builder.setCertificateChain(new X509Certificate[]{serverCertificate}); |
170 | 192 | this.infoParamsServerX509(serverCertificate, publicKey, privateKey); |
171 | 193 | return true; |
172 | - } | |
173 | - else { | |
194 | + } else { | |
174 | 195 | return false; |
175 | 196 | } |
176 | 197 | } catch (Exception ex) { |
... | ... | @@ -181,15 +202,22 @@ public class LwM2MTransportServerConfiguration { |
181 | 202 | |
182 | 203 | private void infoParamsServerX509(X509Certificate certificate, PublicKey publicKey, PrivateKey privateKey) { |
183 | 204 | try { |
184 | - log.info("Server uses X509 : \n X509 Certificate (Hex): [{}] \n Public Key (Hex): [{}] \n Private Key (Hex): [{}]", | |
185 | - Hex.encodeHexString(certificate.getEncoded()), | |
186 | - Hex.encodeHexString(publicKey.getEncoded()), | |
187 | - Hex.encodeHexString(privateKey.getEncoded())); | |
205 | + infoPramsUri("X509"); | |
206 | + log.info("\n- X509 Certificate (Hex): [{}]", | |
207 | + Hex.encodeHexString(certificate.getEncoded())); | |
208 | + this.infoParamsServerKey(publicKey, privateKey); | |
188 | 209 | } catch (CertificateEncodingException e) { |
189 | 210 | log.error("", e); |
190 | 211 | } |
191 | 212 | } |
192 | 213 | |
214 | + private void infoPramsUri(String mode) { | |
215 | + log.info("Server uses [{}]: serverNoSecureURI : [{}], serverSecureURI : [{}]", | |
216 | + mode, | |
217 | + this.context.getCtxServer().getServerHost() + ":" + this.context.getCtxServer().getServerPortNoSec(), | |
218 | + this.context.getCtxServer().getServerHostSecurity() + ":" + this.context.getCtxServer().getServerPortSecurity()); | |
219 | + } | |
220 | + | |
193 | 221 | private boolean setServerRPK(LeshanServerBuilder builder) { |
194 | 222 | try { |
195 | 223 | this.generateKeyForRPK(); |
... | ... | @@ -207,7 +235,7 @@ public class LwM2MTransportServerConfiguration { |
207 | 235 | |
208 | 236 | |
209 | 237 | /** |
210 | - * From yml^ server | |
238 | + * From yml: server | |
211 | 239 | * public_x: "${LWM2M_SERVER_PUBLIC_X:405354ea8893471d9296afbc8b020a5c6201b0bb25812a53b849d4480fa5f069}" |
212 | 240 | * public_y: "${LWM2M_SERVER_PUBLIC_Y:30c9237e946a3a1692c1cafaa01a238a077f632c99371348337512363f28212b}" |
213 | 241 | * private_s: "${LWM2M_SERVER_PRIVATE_S:274671fe40ce937b8a6352cf0a418e8a39e4bf0bb9bf74c910db953c20c73802}" |
... | ... | @@ -241,41 +269,32 @@ public class LwM2MTransportServerConfiguration { |
241 | 269 | } |
242 | 270 | } |
243 | 271 | |
244 | - private void infoParamsServerRPK() { | |
272 | + private void infoParamsServerKey(PublicKey publicKey, PrivateKey privateKey) { | |
245 | 273 | /** Get x coordinate */ |
246 | - byte[] x = ((ECPublicKey) this.publicKey).getW().getAffineX().toByteArray(); | |
274 | + byte[] x = ((ECPublicKey) publicKey).getW().getAffineX().toByteArray(); | |
247 | 275 | if (x[0] == 0) |
248 | 276 | x = Arrays.copyOfRange(x, 1, x.length); |
249 | 277 | |
250 | 278 | /** Get Y coordinate */ |
251 | - byte[] y = ((ECPublicKey) this.publicKey).getW().getAffineY().toByteArray(); | |
279 | + byte[] y = ((ECPublicKey) publicKey).getW().getAffineY().toByteArray(); | |
252 | 280 | if (y[0] == 0) |
253 | 281 | y = Arrays.copyOfRange(y, 1, y.length); |
254 | 282 | |
255 | 283 | /** Get Curves params */ |
256 | - String params = ((ECPublicKey) this.publicKey).getParams().toString(); | |
257 | - String privHex = Hex.encodeHexString(this.privateKey.getEncoded()); | |
258 | - log.info("Server uses RPK -> serverNoSecureURI : [{}], serverSecureURI : [{}], \n" + | |
259 | - "Public Key (Hex): [{}] \n" + | |
260 | - "Private Key (Hex): [{}], \n" + | |
261 | - "- public_x : [{}] \n" + | |
262 | - "- public_y : [{}] \n" + | |
263 | - "- private_s : [{}] \n" + | |
284 | + String params = ((ECPublicKey) publicKey).getParams().toString(); | |
285 | + String privHex = Hex.encodeHexString(privateKey.getEncoded()); | |
286 | + log.info(" \n- Public Key (Hex): [{}] \n" + | |
287 | + "- Private Key (Hex): [{}], \n" + | |
288 | + "public_x: \"${LWM2M_SERVER_PUBLIC_X:{}}\" \n" + | |
289 | + "public_y: \"${LWM2M_SERVER_PUBLIC_Y:{}}\" \n" + | |
290 | + "private_s: \"${LWM2M_SERVER_PRIVATE_S:{}}\" \n" + | |
264 | 291 | "- Elliptic Curve parameters : [{}]", |
265 | - this.context.getCtxServer().getServerHost() + ":" + this.context.getCtxServer().getServerPortNoSec(), | |
266 | - this.context.getCtxServer().getServerHostSecurity() + ":" + this.context.getCtxServer().getServerPortSecurity(), | |
267 | - Hex.encodeHexString(this.publicKey.getEncoded()), | |
268 | - Hex.encodeHexString(this.privateKey.getEncoded()), | |
292 | + Hex.encodeHexString(publicKey.getEncoded()), | |
293 | + privHex, | |
269 | 294 | Hex.encodeHexString(x), |
270 | 295 | Hex.encodeHexString(y), |
271 | 296 | privHex.substring(privHex.length() - 64), |
272 | 297 | params); |
273 | 298 | } |
274 | 299 | |
275 | - private void infoParamsServerPSK() { | |
276 | - log.info("Server uses PSK -> serverNoSecureURI : [{}], serverSecureURI : [{}]", | |
277 | - this.context.getCtxServer().getServerHost() + ":" + Integer.toString(this.context.getCtxServer().getServerPortNoSec()), | |
278 | - this.context.getCtxServer().getServerHostSecurity() + ":" + Integer.toString(this.context.getCtxServer().getServerPortSecurity())); | |
279 | - } | |
280 | - | |
281 | 300 | } | ... | ... |
... | ... | @@ -41,7 +41,7 @@ public class LwM2MTransportServerInitializer { |
41 | 41 | |
42 | 42 | @PostConstruct |
43 | 43 | public void init() { |
44 | - if (this.context.getCtxServer().getEnableGenPskRpk()) { | |
44 | + if (this.context.getCtxServer().getEnableGenNewKeyPskRpk()) { | |
45 | 45 | new LWM2MGenerationPSkRPkECC(); |
46 | 46 | } |
47 | 47 | this.startLhServer(); | ... | ... |
No preview for this file type
1 | -#!/bin/bash | |
1 | +#!/bin/sh | |
2 | 2 | # |
3 | 3 | # Copyright © 2016-2021 The Thingsboard Authors |
4 | 4 | # |
... | ... | @@ -15,77 +15,35 @@ |
15 | 15 | # limitations under the License. |
16 | 16 | # |
17 | 17 | |
18 | -#p) CLIENT_CN=LwX50900000000 | |
18 | +#/home/nick/Igor_project/Thingsboard_Perfrmance_test/performance-tests/src/main/resources/credentials/shell/lwM2M_credentials.sh -p LwX509 -s 0 -f 2000 -a client_alias_ -e client_self_signed_ -b bootstrap -d server -j serverKeyStore.jks -k clientKeyStore.jks -c client_ks_password -w server_ks_password | |
19 | + | |
20 | +#p) CLIENT_CN=$CLIENT_PREFIX00000000 | |
19 | 21 | #s) client_start=0 |
20 | 22 | #f) client_finish=1 |
21 | -#a) CLIENT_ALIAS=client_alias_00000000 | |
23 | +#a) CLIENT_ALIAS=CLIENT_ALIAS_PREFIX_00000000 | |
24 | +#e) CLIENT_SELF_ALIAS=CLIENT_SELF_ALIAS_PREFIX_00000000 | |
22 | 25 | #b) BOOTSTRAP_ALIAS=bootstrap |
23 | 26 | #d) SERVER_ALIAS=server |
24 | 27 | #j) SERVER_STORE=serverKeyStore.jks |
25 | 28 | #k) CLIENT_STORE=clientKeyStore.jks |
26 | 29 | #c) CLIENT_STORE_PWD=client_ks_password |
27 | 30 | #w) SERVER_STORE_PWD=server_ks_password |
31 | +#l) ROOT_KEY_ALIAS=root_key_alias | |
28 | 32 | |
29 | -#while test $# -gt 0; do | |
30 | -# case "$1" in | |
31 | -# -h|--help) | |
32 | -# echo "$package - attempt to capture frames" | |
33 | -# echo " " | |
34 | -# echo "$package [options] application [arguments]" | |
35 | -# echo " " | |
36 | -# echo "options:" | |
37 | -# echo "-h, --help show brief help" | |
38 | -# echo "-a, --action=ACTION specify an action to use" | |
39 | -# echo "-o, --output-dir=DIR specify a directory to store output in" | |
40 | -# exit 0 | |
41 | -# ;; | |
42 | -# -a) | |
43 | -# shift | |
44 | -# if test $# -gt 0; then | |
45 | -# export PROCESS=$1 | |
46 | -# else | |
47 | -# echo "no process specified" | |
48 | -# exit 1 | |
49 | -# fi | |
50 | -# shift | |
51 | -# ;; | |
52 | -# --action*) | |
53 | -# export PROCESS=`echo $1 | sed -e 's/^[^=]*=//g'` | |
54 | -# shift | |
55 | -# ;; | |
56 | -# -o) | |
57 | -# shift | |
58 | -# if test $# -gt 0; then | |
59 | -# export OUTPUT=$1 | |
60 | -# else | |
61 | -# echo "no output dir specified" | |
62 | -# exit 1 | |
63 | -# fi | |
64 | -# shift | |
65 | -# ;; | |
66 | -# --output-dir*) | |
67 | -# export OUTPUT=`echo $1 | sed -e 's/^[^=]*=//g'` | |
68 | -# shift | |
69 | -# ;; | |
70 | -# *) | |
71 | -# break | |
72 | -# ;; | |
73 | -# esac | |
74 | -#done | |
75 | - | |
76 | - | |
77 | -while getopts p:s:f:a:b:d:j:k:c:w: flag; do | |
33 | +while getopts p:s:f:a:e:b:d:j:k:c:w:l: flag; do | |
78 | 34 | case "${flag}" in |
79 | - p) client_prefix=${OPTARG} ;; | |
35 | + p) client_pref=${OPTARG} ;; | |
80 | 36 | s) client_start=${OPTARG} ;; |
81 | 37 | f) client_finish=${OPTARG} ;; |
82 | - a) client_alias=${OPTARG} ;; | |
38 | + a) client_alias_pref=${OPTARG} ;; | |
39 | + e) client_self_alias_pref=${OPTARG} ;; | |
83 | 40 | b) bootstrap_alias=${OPTARG} ;; |
84 | 41 | d) server_alias=${OPTARG} ;; |
85 | 42 | j) key_store_server_file=${OPTARG} ;; |
86 | 43 | k) key_store_client_file=${OPTARG} ;; |
87 | 44 | c) client_key_store_pwd=${OPTARG} ;; |
88 | 45 | w) server_key_store_pwd=${OPTARG} ;; |
46 | + w) root_key_alias=${OPTARG} ;; | |
89 | 47 | esac |
90 | 48 | done |
91 | 49 | |
... | ... | @@ -96,9 +54,8 @@ cd $script_dir |
96 | 54 | # source the properties: |
97 | 55 | . ./lwM2M_keygen.properties |
98 | 56 | |
99 | - | |
100 | -if [ -n "$client_prefix" ]; then | |
101 | - CLIENT_PREFIX=$client_prefix | |
57 | +if [ -n "$client_pref" ]; then | |
58 | + CLIENT_PREFIX=$client_pref | |
102 | 59 | fi |
103 | 60 | |
104 | 61 | if [ -z "$client_start" ]; then |
... | ... | @@ -109,8 +66,12 @@ if [ -z "$client_finish" ]; then |
109 | 66 | client_finish=1 |
110 | 67 | fi |
111 | 68 | |
112 | -if [ -n "$client_alias" ]; then | |
113 | - CLIENT_ALIAS=$client_alias | |
69 | +if [ -n "$client_alias_pref" ]; then | |
70 | + CLIENT_ALIAS_PREFIX=$client_alias_pref | |
71 | +fi | |
72 | + | |
73 | +if [ -n "$client_self_alias_pref" ]; then | |
74 | + CLIENT_SELF_ALIAS_PREFIX=$client_self_alias_pref | |
114 | 75 | fi |
115 | 76 | |
116 | 77 | if [ -n "$bootstrap_alias" ]; then |
... | ... | @@ -137,23 +98,37 @@ if [ -n "$server_key_store_pwd" ]; then |
137 | 98 | SERVER_STORE_PWD=$server_key_store_pwd |
138 | 99 | fi |
139 | 100 | |
101 | +if [ -n "$root_key_alias" ]; then | |
102 | + ROOT_KEY_ALIAS=$root_key_alias | |
103 | +fi | |
104 | + | |
105 | +CLIENT_NUMBER=$client_start | |
106 | + | |
140 | 107 | echo "==Start==" |
141 | 108 | echo "CLIENT_PREFIX: $CLIENT_PREFIX" |
142 | 109 | echo "client_start: $client_start" |
143 | 110 | echo "client_finish: $client_finish" |
144 | -echo "CLIENT_ALIAS: $CLIENT_ALIAS" | |
111 | +echo "CLIENT_ALIAS_PREFIX: $CLIENT_ALIAS_PREFIX" | |
112 | +echo "CLIENT_SELF_ALIAS_PREFIX: $CLIENT_SELF_ALIAS_PREFIX" | |
145 | 113 | echo "BOOTSTRAP_ALIAS: $BOOTSTRAP_ALIAS" |
146 | 114 | echo "SERVER_ALIAS: $SERVER_ALIAS" |
147 | 115 | echo "SERVER_STORE: $SERVER_STORE" |
148 | 116 | echo "CLIENT_STORE: $CLIENT_STORE" |
149 | 117 | echo "CLIENT_STORE_PWD: $CLIENT_STORE_PWD" |
150 | 118 | echo "SERVER_STORE_PWD: $SERVER_STORE_PWD" |
119 | +echo "CLIENT_NUMBER: $CLIENT_NUMBER" | |
120 | +echo "ROOT_KEY_ALIAS: $ROOT_KEY_ALIAS" | |
151 | 121 | |
152 | 122 | end_point() { |
153 | 123 | echo "$CLIENT_PREFIX$(printf "%08d" $CLIENT_NUMBER)" |
154 | 124 | } |
125 | + | |
155 | 126 | client_alias_point() { |
156 | - echo "$CLIENT_ALIAS$(printf "%08d" $CLIENT_NUMBER)" | |
127 | + echo "$CLIENT_ALIAS_PREFIX$(printf "%08d" $CLIENT_NUMBER)" | |
128 | +} | |
129 | + | |
130 | +client_self_alias_point() { | |
131 | + echo "$CLIENT_SELF_ALIAS_PREFIX$(printf "%08d" $CLIENT_NUMBER)" | |
157 | 132 | } |
158 | 133 | |
159 | 134 | # Generation of the keystore. |
... | ... | @@ -264,73 +239,30 @@ keytool \ |
264 | 239 | -keystore $SERVER_STORE \ |
265 | 240 | -storepass $SERVER_STORE_PWD |
266 | 241 | |
267 | -echo | |
268 | -echo "${H1}Client Keystore : ${RESET}" | |
269 | -echo "${H1}==================${RESET}" | |
270 | -#echo "${H2}Creating client key and self-signed certificate with expected CN...${RESET}" | |
271 | -#keytool \ | |
272 | -# -genkeypair \ | |
273 | -# -alias $CLIENT_ALIAS \ | |
274 | -# -keyalg EC \ | |
275 | -# -dname "CN=$CLIENT_SELF_CN, OU=$ORGANIZATIONAL_UNIT, O=$ORGANIZATION, L=$CITY, ST=$STATE_OR_PROVINCE, C=$TWO_LETTER_COUNTRY_CODE" \ | |
276 | -# -validity $VALIDITY \ | |
277 | -# -storetype $STORETYPE \ | |
278 | -# -keypass $CLIENT_STORE_PWD \ | |
279 | -# -keystore $CLIENT_STORE \ | |
280 | -# -storepass $CLIENT_STORE_PWD | |
281 | -#keytool \ | |
282 | -# -exportcert \ | |
283 | -# -alias $CLIENT_ALIAS \ | |
284 | -# -keystore $CLIENT_STORE \ | |
285 | -# -storepass $CLIENT_STORE_PWD | \ | |
286 | -# keytool \ | |
287 | -# -importcert \ | |
288 | -# -alias $CLIENT_SELF_ALIAS \ | |
289 | -# -keystore $CLIENT_STORE \ | |
290 | -# -storepass $CLIENT_STORE_PWD \ | |
291 | -# -noprompt | |
292 | - | |
293 | -echo | |
294 | -echo "${H2}Import root certificate just to be able to import need by root CA with expected CN...${RESET}" | |
295 | -keytool \ | |
296 | - -exportcert \ | |
297 | - -alias $ROOT_KEY_ALIAS \ | |
298 | - -keystore $SERVER_STORE \ | |
299 | - -storepass $SERVER_STORE_PWD | | |
242 | +if [ "$client_start" -lt "$client_finish" ]; then | |
243 | + echo | |
244 | + echo "${H2}Import root certificate just to be able to import need by root CA with expected CN to $CLIENT_STORE${RESET}" | |
300 | 245 | keytool \ |
301 | - -importcert \ | |
246 | + -exportcert \ | |
302 | 247 | -alias $ROOT_KEY_ALIAS \ |
303 | - -keystore $CLIENT_STORE \ | |
304 | - -storepass $CLIENT_STORE_PWD \ | |
305 | - -noprompt | |
306 | - | |
307 | -#echo | |
308 | -#echo "${H2}Creating client certificate signed by root CA with expected CN...${RESET}" | |
309 | -#keytool \ | |
310 | -# -certreq \ | |
311 | -# -alias $CLIENT_ALIAS \ | |
312 | -# -dname "CN=$CLIENT_CN, OU=$ORGANIZATIONAL_UNIT, O=$ORGANIZATION, L=$CITY, ST=$STATE_OR_PROVINCE, C=$TWO_LETTER_COUNTRY_CODE" \ | |
313 | -# -keystore $CLIENT_STORE \ | |
314 | -# -storepass $CLIENT_STORE_PWD | \ | |
315 | -# keytool \ | |
316 | -# -gencert \ | |
317 | -# -alias $ROOT_KEY_ALIAS \ | |
318 | -# -keystore $SERVER_STORE \ | |
319 | -# -storepass $SERVER_STORE_PWD \ | |
320 | -# -storetype $STORETYPE \ | |
321 | -# -validity $VALIDITY | \ | |
322 | -# keytool \ | |
323 | -# -importcert \ | |
324 | -# -alias $CLIENT_ALIAS \ | |
325 | -# -keystore $CLIENT_STORE \ | |
326 | -# -storepass $CLIENT_STORE_PWD \ | |
327 | -# -noprompt | |
248 | + -keystore $SERVER_STORE \ | |
249 | + -storepass $SERVER_STORE_PWD | | |
250 | + keytool \ | |
251 | + -importcert \ | |
252 | + -alias $ROOT_KEY_ALIAS \ | |
253 | + -keystore $CLIENT_STORE \ | |
254 | + -storepass $CLIENT_STORE_PWD \ | |
255 | + -noprompt | |
256 | +fi | |
328 | 257 | |
329 | 258 | cert_end_point() { |
330 | - echo "${H2}Creating client key and self-signed certificate with expected CN $CLIENT_SELF_CN ${RESET}" | |
259 | + echo | |
260 | + echo "${H1}Client Keystore : ${RESET}" | |
261 | + echo "${H1}==================${RESET}" | |
262 | + echo "${H2}Creating client key and self-signed certificate with expected CN CLIENT_ALIAS: $CLIENT_ALIAS${RESET}" | |
331 | 263 | keytool \ |
332 | 264 | -genkeypair \ |
333 | - -alias $CLIENT_CN_ALIAS \ | |
265 | + -alias $CLIENT_ALIAS \ | |
334 | 266 | -keyalg EC \ |
335 | 267 | -dname "CN=$CLIENT_SELF_CN, OU=$ORGANIZATIONAL_UNIT, O=$ORGANIZATION, L=$CITY, ST=$STATE_OR_PROVINCE, C=$TWO_LETTER_COUNTRY_CODE" \ |
336 | 268 | -validity $VALIDITY \ |
... | ... | @@ -340,7 +272,7 @@ cert_end_point() { |
340 | 272 | -storepass $CLIENT_STORE_PWD |
341 | 273 | keytool \ |
342 | 274 | -exportcert \ |
343 | - -alias $CLIENT_CN_ALIAS \ | |
275 | + -alias $CLIENT_ALIAS \ | |
344 | 276 | -keystore $CLIENT_STORE \ |
345 | 277 | -storepass $CLIENT_STORE_PWD | |
346 | 278 | keytool \ |
... | ... | @@ -349,13 +281,28 @@ cert_end_point() { |
349 | 281 | -keystore $CLIENT_STORE \ |
350 | 282 | -storepass $CLIENT_STORE_PWD \ |
351 | 283 | -noprompt |
284 | +# | |
285 | +# echo | |
286 | +# echo "${H2}Import root certificate just to be able to import ned by root CA with expected CN...${RESET}" | |
287 | +# keytool \ | |
288 | +# -exportcert \ | |
289 | +# -alias $ROOT_KEY_ALIAS \ | |
290 | +# -keystore $SERVER_STORE \ | |
291 | +# -storepass $SERVER_STORE_PWD | | |
292 | +# keytool \ | |
293 | +# -importcert \ | |
294 | +# -alias $ROOT_KEY_ALIAS \ | |
295 | +# -keystore $CLIENT_STORE \ | |
296 | +# -storepass $CLIENT_STORE_PWD \ | |
297 | +# -noprompt | |
298 | +# | |
352 | 299 | |
353 | 300 | echo |
354 | - echo "${H2}Creating client certificate signed by root CA with expected $CLIENT_CN_NAME ${RESET}" | |
301 | + echo "${H2}Creating client certificate signed by root CA with expected CN CLIENT_ALIAS: $CLIENT_ALIAS CLIENT_CN: $CLIENT_CN${RESET}" | |
355 | 302 | keytool \ |
356 | 303 | -certreq \ |
357 | - -alias $CLIENT_CN_ALIAS \ | |
358 | - -dname "CN=$CLIENT_CN_NAME, OU=$ORGANIZATIONAL_UNIT, O=$ORGANIZATION, L=$CITY, ST=$STATE_OR_PROVINCE, C=$TWO_LETTER_COUNTRY_CODE" \ | |
304 | + -alias $CLIENT_ALIAS \ | |
305 | + -dname "CN=$CLIENT_CN, OU=$ORGANIZATIONAL_UNIT, O=$ORGANIZATION, L=$CITY, ST=$STATE_OR_PROVINCE, C=$TWO_LETTER_COUNTRY_CODE" \ | |
359 | 306 | -keystore $CLIENT_STORE \ |
360 | 307 | -storepass $CLIENT_STORE_PWD | |
361 | 308 | keytool \ |
... | ... | @@ -367,22 +314,30 @@ cert_end_point() { |
367 | 314 | -validity $VALIDITY | |
368 | 315 | keytool \ |
369 | 316 | -importcert \ |
370 | - -alias $CLIENT_CN_ALIAS \ | |
317 | + -alias $CLIENT_ALIAS \ | |
371 | 318 | -keystore $CLIENT_STORE \ |
372 | 319 | -storepass $CLIENT_STORE_PWD \ |
373 | 320 | -noprompt |
374 | 321 | } |
375 | 322 | |
376 | -while [ "$CLIENT_NUMBER" != "$client_finish" ]; do | |
377 | - CLIENT_CN_NAME=$(end_point) | |
378 | - CLIENT_CN_ALIAS=$(client_alias_point) | |
379 | - echo "$CLIENT_CN_NAME" | |
380 | - echo "$CLIENT_CN_ALIAS" | |
381 | - cert_end_point | |
382 | - CLIENT_NUMBER=$(($CLIENT_NUMBER + 1)) | |
383 | - echo "number $CLIENT_NUMBER" | |
384 | - echo "finish $client_finish" | |
385 | -done | |
323 | +if [ "$client_start" -lt "$client_finish" ]; then | |
324 | + echo "Файл содержит, как минимум, одно слово Bash." | |
325 | + echo | |
326 | + echo "==Start Client==" | |
327 | + while [ "$CLIENT_NUMBER" -lt "$client_finish" ]; do | |
328 | + echo "number $CLIENT_NUMBER" | |
329 | + echo "finish $client_finish" | |
330 | + CLIENT_CN=$(end_point) | |
331 | + CLIENT_ALIAS=$(client_alias_point) | |
332 | + CLIENT_SELF_ALIAS=$(client_self_alias_point) | |
333 | + echo "CLIENT_CN $CLIENT_CN" | |
334 | + echo "CLIENT_ALIAS $CLIENT_ALIAS" | |
335 | + echo "CLIENT_SELF_ALIAS $CLIENT_SELF_ALIAS" | |
336 | + cert_end_point | |
337 | + CLIENT_NUMBER=$(($CLIENT_NUMBER + 1)) | |
338 | + echo | |
339 | + done | |
340 | +fi | |
386 | 341 | |
387 | 342 | echo |
388 | 343 | echo "${H0}!!! Warning ${H2}Migrate ${H1}${SERVER_STORE} ${H2}to ${H1}PKCS12 ${H2}which is an industry standard format..${RESET}" |
... | ... | @@ -393,11 +348,13 @@ keytool \ |
393 | 348 | -deststoretype pkcs12 \ |
394 | 349 | -srcstorepass $SERVER_STORE_PWD |
395 | 350 | |
396 | -echo | |
397 | -echo "${H0}!!! Warning ${H2}Migrate ${H1}${CLIENT_STORE} ${H2}to ${H1}PKCS12 ${H2}which is an industry standard format..${RESET}" | |
398 | -keytool \ | |
399 | - -importkeystore \ | |
400 | - -srckeystore $CLIENT_STORE \ | |
401 | - -destkeystore $CLIENT_STORE \ | |
402 | - -deststoretype pkcs12 \ | |
403 | - -srcstorepass $CLIENT_STORE_PWD | |
351 | +if [ "$client_start" -lt "$client_finish" ]; then | |
352 | + echo | |
353 | + echo "${H0}!!! Warning ${H2}Migrate ${H1}${CLIENT_STORE} ${H2}to ${H1}PKCS12 ${H2}which is an industry standard format..${RESET}" | |
354 | + keytool \ | |
355 | + -importkeystore \ | |
356 | + -srckeystore $CLIENT_STORE \ | |
357 | + -destkeystore $CLIENT_STORE \ | |
358 | + -deststoretype pkcs12 \ | |
359 | + -srcstorepass $CLIENT_STORE_PWD | |
360 | +fi | ... | ... |
... | ... | @@ -41,9 +41,9 @@ BOOTSTRAP_SELF_CN="$DOMAIN_SUFFIX bootstrap server LwM2M self-signed" |
41 | 41 | # Client |
42 | 42 | CLIENT_STORE=clientKeyStore1.jks |
43 | 43 | CLIENT_STORE_PWD=client_ks_password1 |
44 | -CLIENT_ALIAS=client_alias_1 | |
45 | -CLIENT_PREFIX=LwX509_ | |
46 | -CLIENT_SELF_ALIAS=client_self_signed | |
44 | +CLIENT_ALIAS_PREFIX=client_alias_1 | |
45 | +CLIENT_PREFIX=LwX509___ | |
46 | +CLIENT_SELF_ALIAS_PREFIX=client_self_signed_1 | |
47 | 47 | CLIENT_SELF_CN="$DOMAIN_SUFFIX client LwM2M self-signed" |
48 | 48 | |
49 | 49 | # Color output stuff | ... | ... |
... | ... | @@ -147,8 +147,8 @@ public class LwM2MTransportConfigServer { |
147 | 147 | private String rootAlias; |
148 | 148 | |
149 | 149 | @Getter |
150 | - @Value("${transport.lwm2m.secure.enable_gen_psk_rpk:}") | |
151 | - private Boolean enableGenPskRpk; | |
150 | + @Value("${transport.lwm2m.secure.enable_gen_new_key_psk_rpk:}") | |
151 | + private Boolean enableGenNewKeyPskRpk; | |
152 | 152 | |
153 | 153 | @Getter |
154 | 154 | @Value("${transport.lwm2m.server.id:}") | ... | ... |
No preview for this file type
1 | -#!/bin/bash | |
1 | +#!/bin/sh | |
2 | 2 | # |
3 | 3 | # Copyright © 2016-2021 The Thingsboard Authors |
4 | 4 | # |
... | ... | @@ -15,77 +15,35 @@ |
15 | 15 | # limitations under the License. |
16 | 16 | # |
17 | 17 | |
18 | -#p) CLIENT_CN=LwX50900000000 | |
18 | +#/home/nick/Igor_project/Thingsboard_Perfrmance_test/performance-tests/src/main/resources/credentials/shell/lwM2M_credentials.sh -p LwX509 -s 0 -f 2000 -a client_alias_ -e client_self_signed_ -b bootstrap -d server -j serverKeyStore.jks -k clientKeyStore.jks -c client_ks_password -w server_ks_password | |
19 | + | |
20 | +#p) CLIENT_CN=$CLIENT_PREFIX00000000 | |
19 | 21 | #s) client_start=0 |
20 | 22 | #f) client_finish=1 |
21 | -#a) CLIENT_ALIAS=client_alias_00000000 | |
23 | +#a) CLIENT_ALIAS=CLIENT_ALIAS_PREFIX_00000000 | |
24 | +#e) CLIENT_SELF_ALIAS=CLIENT_SELF_ALIAS_PREFIX_00000000 | |
22 | 25 | #b) BOOTSTRAP_ALIAS=bootstrap |
23 | 26 | #d) SERVER_ALIAS=server |
24 | 27 | #j) SERVER_STORE=serverKeyStore.jks |
25 | 28 | #k) CLIENT_STORE=clientKeyStore.jks |
26 | 29 | #c) CLIENT_STORE_PWD=client_ks_password |
27 | 30 | #w) SERVER_STORE_PWD=server_ks_password |
31 | +#l) ROOT_KEY_ALIAS=root_key_alias | |
28 | 32 | |
29 | -#while test $# -gt 0; do | |
30 | -# case "$1" in | |
31 | -# -h|--help) | |
32 | -# echo "$package - attempt to capture frames" | |
33 | -# echo " " | |
34 | -# echo "$package [options] application [arguments]" | |
35 | -# echo " " | |
36 | -# echo "options:" | |
37 | -# echo "-h, --help show brief help" | |
38 | -# echo "-a, --action=ACTION specify an action to use" | |
39 | -# echo "-o, --output-dir=DIR specify a directory to store output in" | |
40 | -# exit 0 | |
41 | -# ;; | |
42 | -# -a) | |
43 | -# shift | |
44 | -# if test $# -gt 0; then | |
45 | -# export PROCESS=$1 | |
46 | -# else | |
47 | -# echo "no process specified" | |
48 | -# exit 1 | |
49 | -# fi | |
50 | -# shift | |
51 | -# ;; | |
52 | -# --action*) | |
53 | -# export PROCESS=`echo $1 | sed -e 's/^[^=]*=//g'` | |
54 | -# shift | |
55 | -# ;; | |
56 | -# -o) | |
57 | -# shift | |
58 | -# if test $# -gt 0; then | |
59 | -# export OUTPUT=$1 | |
60 | -# else | |
61 | -# echo "no output dir specified" | |
62 | -# exit 1 | |
63 | -# fi | |
64 | -# shift | |
65 | -# ;; | |
66 | -# --output-dir*) | |
67 | -# export OUTPUT=`echo $1 | sed -e 's/^[^=]*=//g'` | |
68 | -# shift | |
69 | -# ;; | |
70 | -# *) | |
71 | -# break | |
72 | -# ;; | |
73 | -# esac | |
74 | -#done | |
75 | - | |
76 | - | |
77 | -while getopts p:s:f:a:b:d:j:k:c:w: flag; do | |
33 | +while getopts p:s:f:a:e:b:d:j:k:c:w:l: flag; do | |
78 | 34 | case "${flag}" in |
79 | - p) client_prefix=${OPTARG} ;; | |
35 | + p) client_pref=${OPTARG} ;; | |
80 | 36 | s) client_start=${OPTARG} ;; |
81 | 37 | f) client_finish=${OPTARG} ;; |
82 | - a) client_alias=${OPTARG} ;; | |
38 | + a) client_alias_pref=${OPTARG} ;; | |
39 | + e) client_self_alias_pref=${OPTARG} ;; | |
83 | 40 | b) bootstrap_alias=${OPTARG} ;; |
84 | 41 | d) server_alias=${OPTARG} ;; |
85 | 42 | j) key_store_server_file=${OPTARG} ;; |
86 | 43 | k) key_store_client_file=${OPTARG} ;; |
87 | 44 | c) client_key_store_pwd=${OPTARG} ;; |
88 | 45 | w) server_key_store_pwd=${OPTARG} ;; |
46 | + w) root_key_alias=${OPTARG} ;; | |
89 | 47 | esac |
90 | 48 | done |
91 | 49 | |
... | ... | @@ -96,9 +54,8 @@ cd $script_dir |
96 | 54 | # source the properties: |
97 | 55 | . ./lwM2M_keygen.properties |
98 | 56 | |
99 | - | |
100 | -if [ -n "$client_prefix" ]; then | |
101 | - CLIENT_PREFIX=$client_prefix | |
57 | +if [ -n "$client_pref" ]; then | |
58 | + CLIENT_PREFIX=$client_pref | |
102 | 59 | fi |
103 | 60 | |
104 | 61 | if [ -z "$client_start" ]; then |
... | ... | @@ -109,8 +66,12 @@ if [ -z "$client_finish" ]; then |
109 | 66 | client_finish=1 |
110 | 67 | fi |
111 | 68 | |
112 | -if [ -n "$client_alias" ]; then | |
113 | - CLIENT_ALIAS=$client_alias | |
69 | +if [ -n "$client_alias_pref" ]; then | |
70 | + CLIENT_ALIAS_PREFIX=$client_alias_pref | |
71 | +fi | |
72 | + | |
73 | +if [ -n "$client_self_alias_pref" ]; then | |
74 | + CLIENT_SELF_ALIAS_PREFIX=$client_self_alias_pref | |
114 | 75 | fi |
115 | 76 | |
116 | 77 | if [ -n "$bootstrap_alias" ]; then |
... | ... | @@ -137,23 +98,37 @@ if [ -n "$server_key_store_pwd" ]; then |
137 | 98 | SERVER_STORE_PWD=$server_key_store_pwd |
138 | 99 | fi |
139 | 100 | |
101 | +if [ -n "$root_key_alias" ]; then | |
102 | + ROOT_KEY_ALIAS=$root_key_alias | |
103 | +fi | |
104 | + | |
105 | +CLIENT_NUMBER=$client_start | |
106 | + | |
140 | 107 | echo "==Start==" |
141 | 108 | echo "CLIENT_PREFIX: $CLIENT_PREFIX" |
142 | 109 | echo "client_start: $client_start" |
143 | 110 | echo "client_finish: $client_finish" |
144 | -echo "CLIENT_ALIAS: $CLIENT_ALIAS" | |
111 | +echo "CLIENT_ALIAS_PREFIX: $CLIENT_ALIAS_PREFIX" | |
112 | +echo "CLIENT_SELF_ALIAS_PREFIX: $CLIENT_SELF_ALIAS_PREFIX" | |
145 | 113 | echo "BOOTSTRAP_ALIAS: $BOOTSTRAP_ALIAS" |
146 | 114 | echo "SERVER_ALIAS: $SERVER_ALIAS" |
147 | 115 | echo "SERVER_STORE: $SERVER_STORE" |
148 | 116 | echo "CLIENT_STORE: $CLIENT_STORE" |
149 | 117 | echo "CLIENT_STORE_PWD: $CLIENT_STORE_PWD" |
150 | 118 | echo "SERVER_STORE_PWD: $SERVER_STORE_PWD" |
119 | +echo "CLIENT_NUMBER: $CLIENT_NUMBER" | |
120 | +echo "ROOT_KEY_ALIAS: $ROOT_KEY_ALIAS" | |
151 | 121 | |
152 | 122 | end_point() { |
153 | 123 | echo "$CLIENT_PREFIX$(printf "%08d" $CLIENT_NUMBER)" |
154 | 124 | } |
125 | + | |
155 | 126 | client_alias_point() { |
156 | - echo "$CLIENT_ALIAS$(printf "%08d" $CLIENT_NUMBER)" | |
127 | + echo "$CLIENT_ALIAS_PREFIX$(printf "%08d" $CLIENT_NUMBER)" | |
128 | +} | |
129 | + | |
130 | +client_self_alias_point() { | |
131 | + echo "$CLIENT_SELF_ALIAS_PREFIX$(printf "%08d" $CLIENT_NUMBER)" | |
157 | 132 | } |
158 | 133 | |
159 | 134 | # Generation of the keystore. |
... | ... | @@ -264,73 +239,30 @@ keytool \ |
264 | 239 | -keystore $SERVER_STORE \ |
265 | 240 | -storepass $SERVER_STORE_PWD |
266 | 241 | |
267 | -echo | |
268 | -echo "${H1}Client Keystore : ${RESET}" | |
269 | -echo "${H1}==================${RESET}" | |
270 | -#echo "${H2}Creating client key and self-signed certificate with expected CN...${RESET}" | |
271 | -#keytool \ | |
272 | -# -genkeypair \ | |
273 | -# -alias $CLIENT_ALIAS \ | |
274 | -# -keyalg EC \ | |
275 | -# -dname "CN=$CLIENT_SELF_CN, OU=$ORGANIZATIONAL_UNIT, O=$ORGANIZATION, L=$CITY, ST=$STATE_OR_PROVINCE, C=$TWO_LETTER_COUNTRY_CODE" \ | |
276 | -# -validity $VALIDITY \ | |
277 | -# -storetype $STORETYPE \ | |
278 | -# -keypass $CLIENT_STORE_PWD \ | |
279 | -# -keystore $CLIENT_STORE \ | |
280 | -# -storepass $CLIENT_STORE_PWD | |
281 | -#keytool \ | |
282 | -# -exportcert \ | |
283 | -# -alias $CLIENT_ALIAS \ | |
284 | -# -keystore $CLIENT_STORE \ | |
285 | -# -storepass $CLIENT_STORE_PWD | \ | |
286 | -# keytool \ | |
287 | -# -importcert \ | |
288 | -# -alias $CLIENT_SELF_ALIAS \ | |
289 | -# -keystore $CLIENT_STORE \ | |
290 | -# -storepass $CLIENT_STORE_PWD \ | |
291 | -# -noprompt | |
292 | - | |
293 | -echo | |
294 | -echo "${H2}Import root certificate just to be able to import need by root CA with expected CN...${RESET}" | |
295 | -keytool \ | |
296 | - -exportcert \ | |
297 | - -alias $ROOT_KEY_ALIAS \ | |
298 | - -keystore $SERVER_STORE \ | |
299 | - -storepass $SERVER_STORE_PWD | | |
242 | +if [ "$client_start" -lt "$client_finish" ]; then | |
243 | + echo | |
244 | + echo "${H2}Import root certificate just to be able to import need by root CA with expected CN to $CLIENT_STORE${RESET}" | |
300 | 245 | keytool \ |
301 | - -importcert \ | |
246 | + -exportcert \ | |
302 | 247 | -alias $ROOT_KEY_ALIAS \ |
303 | - -keystore $CLIENT_STORE \ | |
304 | - -storepass $CLIENT_STORE_PWD \ | |
305 | - -noprompt | |
306 | - | |
307 | -#echo | |
308 | -#echo "${H2}Creating client certificate signed by root CA with expected CN...${RESET}" | |
309 | -#keytool \ | |
310 | -# -certreq \ | |
311 | -# -alias $CLIENT_ALIAS \ | |
312 | -# -dname "CN=$CLIENT_CN, OU=$ORGANIZATIONAL_UNIT, O=$ORGANIZATION, L=$CITY, ST=$STATE_OR_PROVINCE, C=$TWO_LETTER_COUNTRY_CODE" \ | |
313 | -# -keystore $CLIENT_STORE \ | |
314 | -# -storepass $CLIENT_STORE_PWD | \ | |
315 | -# keytool \ | |
316 | -# -gencert \ | |
317 | -# -alias $ROOT_KEY_ALIAS \ | |
318 | -# -keystore $SERVER_STORE \ | |
319 | -# -storepass $SERVER_STORE_PWD \ | |
320 | -# -storetype $STORETYPE \ | |
321 | -# -validity $VALIDITY | \ | |
322 | -# keytool \ | |
323 | -# -importcert \ | |
324 | -# -alias $CLIENT_ALIAS \ | |
325 | -# -keystore $CLIENT_STORE \ | |
326 | -# -storepass $CLIENT_STORE_PWD \ | |
327 | -# -noprompt | |
248 | + -keystore $SERVER_STORE \ | |
249 | + -storepass $SERVER_STORE_PWD | | |
250 | + keytool \ | |
251 | + -importcert \ | |
252 | + -alias $ROOT_KEY_ALIAS \ | |
253 | + -keystore $CLIENT_STORE \ | |
254 | + -storepass $CLIENT_STORE_PWD \ | |
255 | + -noprompt | |
256 | +fi | |
328 | 257 | |
329 | 258 | cert_end_point() { |
330 | - echo "${H2}Creating client key and self-signed certificate with expected CN $CLIENT_SELF_CN ${RESET}" | |
259 | + echo | |
260 | + echo "${H1}Client Keystore : ${RESET}" | |
261 | + echo "${H1}==================${RESET}" | |
262 | + echo "${H2}Creating client key and self-signed certificate with expected CN CLIENT_ALIAS: $CLIENT_ALIAS${RESET}" | |
331 | 263 | keytool \ |
332 | 264 | -genkeypair \ |
333 | - -alias $CLIENT_CN_ALIAS \ | |
265 | + -alias $CLIENT_ALIAS \ | |
334 | 266 | -keyalg EC \ |
335 | 267 | -dname "CN=$CLIENT_SELF_CN, OU=$ORGANIZATIONAL_UNIT, O=$ORGANIZATION, L=$CITY, ST=$STATE_OR_PROVINCE, C=$TWO_LETTER_COUNTRY_CODE" \ |
336 | 268 | -validity $VALIDITY \ |
... | ... | @@ -340,7 +272,7 @@ cert_end_point() { |
340 | 272 | -storepass $CLIENT_STORE_PWD |
341 | 273 | keytool \ |
342 | 274 | -exportcert \ |
343 | - -alias $CLIENT_CN_ALIAS \ | |
275 | + -alias $CLIENT_ALIAS \ | |
344 | 276 | -keystore $CLIENT_STORE \ |
345 | 277 | -storepass $CLIENT_STORE_PWD | |
346 | 278 | keytool \ |
... | ... | @@ -349,13 +281,28 @@ cert_end_point() { |
349 | 281 | -keystore $CLIENT_STORE \ |
350 | 282 | -storepass $CLIENT_STORE_PWD \ |
351 | 283 | -noprompt |
284 | +# | |
285 | +# echo | |
286 | +# echo "${H2}Import root certificate just to be able to import ned by root CA with expected CN...${RESET}" | |
287 | +# keytool \ | |
288 | +# -exportcert \ | |
289 | +# -alias $ROOT_KEY_ALIAS \ | |
290 | +# -keystore $SERVER_STORE \ | |
291 | +# -storepass $SERVER_STORE_PWD | | |
292 | +# keytool \ | |
293 | +# -importcert \ | |
294 | +# -alias $ROOT_KEY_ALIAS \ | |
295 | +# -keystore $CLIENT_STORE \ | |
296 | +# -storepass $CLIENT_STORE_PWD \ | |
297 | +# -noprompt | |
298 | +# | |
352 | 299 | |
353 | 300 | echo |
354 | - echo "${H2}Creating client certificate signed by root CA with expected $CLIENT_CN_NAME ${RESET}" | |
301 | + echo "${H2}Creating client certificate signed by root CA with expected CN CLIENT_ALIAS: $CLIENT_ALIAS CLIENT_CN: $CLIENT_CN${RESET}" | |
355 | 302 | keytool \ |
356 | 303 | -certreq \ |
357 | - -alias $CLIENT_CN_ALIAS \ | |
358 | - -dname "CN=$CLIENT_CN_NAME, OU=$ORGANIZATIONAL_UNIT, O=$ORGANIZATION, L=$CITY, ST=$STATE_OR_PROVINCE, C=$TWO_LETTER_COUNTRY_CODE" \ | |
304 | + -alias $CLIENT_ALIAS \ | |
305 | + -dname "CN=$CLIENT_CN, OU=$ORGANIZATIONAL_UNIT, O=$ORGANIZATION, L=$CITY, ST=$STATE_OR_PROVINCE, C=$TWO_LETTER_COUNTRY_CODE" \ | |
359 | 306 | -keystore $CLIENT_STORE \ |
360 | 307 | -storepass $CLIENT_STORE_PWD | |
361 | 308 | keytool \ |
... | ... | @@ -367,22 +314,30 @@ cert_end_point() { |
367 | 314 | -validity $VALIDITY | |
368 | 315 | keytool \ |
369 | 316 | -importcert \ |
370 | - -alias $CLIENT_CN_ALIAS \ | |
317 | + -alias $CLIENT_ALIAS \ | |
371 | 318 | -keystore $CLIENT_STORE \ |
372 | 319 | -storepass $CLIENT_STORE_PWD \ |
373 | 320 | -noprompt |
374 | 321 | } |
375 | 322 | |
376 | -while [ "$CLIENT_NUMBER" != "$client_finish" ]; do | |
377 | - CLIENT_CN_NAME=$(end_point) | |
378 | - CLIENT_CN_ALIAS=$(client_alias_point) | |
379 | - echo "$CLIENT_CN_NAME" | |
380 | - echo "$CLIENT_CN_ALIAS" | |
381 | - cert_end_point | |
382 | - CLIENT_NUMBER=$(($CLIENT_NUMBER + 1)) | |
383 | - echo "number $CLIENT_NUMBER" | |
384 | - echo "finish $client_finish" | |
385 | -done | |
323 | +if [ "$client_start" -lt "$client_finish" ]; then | |
324 | + echo "Файл содержит, как минимум, одно слово Bash." | |
325 | + echo | |
326 | + echo "==Start Client==" | |
327 | + while [ "$CLIENT_NUMBER" -lt "$client_finish" ]; do | |
328 | + echo "number $CLIENT_NUMBER" | |
329 | + echo "finish $client_finish" | |
330 | + CLIENT_CN=$(end_point) | |
331 | + CLIENT_ALIAS=$(client_alias_point) | |
332 | + CLIENT_SELF_ALIAS=$(client_self_alias_point) | |
333 | + echo "CLIENT_CN $CLIENT_CN" | |
334 | + echo "CLIENT_ALIAS $CLIENT_ALIAS" | |
335 | + echo "CLIENT_SELF_ALIAS $CLIENT_SELF_ALIAS" | |
336 | + cert_end_point | |
337 | + CLIENT_NUMBER=$(($CLIENT_NUMBER + 1)) | |
338 | + echo | |
339 | + done | |
340 | +fi | |
386 | 341 | |
387 | 342 | echo |
388 | 343 | echo "${H0}!!! Warning ${H2}Migrate ${H1}${SERVER_STORE} ${H2}to ${H1}PKCS12 ${H2}which is an industry standard format..${RESET}" |
... | ... | @@ -393,11 +348,13 @@ keytool \ |
393 | 348 | -deststoretype pkcs12 \ |
394 | 349 | -srcstorepass $SERVER_STORE_PWD |
395 | 350 | |
396 | -echo | |
397 | -echo "${H0}!!! Warning ${H2}Migrate ${H1}${CLIENT_STORE} ${H2}to ${H1}PKCS12 ${H2}which is an industry standard format..${RESET}" | |
398 | -keytool \ | |
399 | - -importkeystore \ | |
400 | - -srckeystore $CLIENT_STORE \ | |
401 | - -destkeystore $CLIENT_STORE \ | |
402 | - -deststoretype pkcs12 \ | |
403 | - -srcstorepass $CLIENT_STORE_PWD | |
351 | +if [ "$client_start" -lt "$client_finish" ]; then | |
352 | + echo | |
353 | + echo "${H0}!!! Warning ${H2}Migrate ${H1}${CLIENT_STORE} ${H2}to ${H1}PKCS12 ${H2}which is an industry standard format..${RESET}" | |
354 | + keytool \ | |
355 | + -importkeystore \ | |
356 | + -srckeystore $CLIENT_STORE \ | |
357 | + -destkeystore $CLIENT_STORE \ | |
358 | + -deststoretype pkcs12 \ | |
359 | + -srcstorepass $CLIENT_STORE_PWD | |
360 | +fi | ... | ... |
... | ... | @@ -41,9 +41,9 @@ BOOTSTRAP_SELF_CN="$DOMAIN_SUFFIX bootstrap server LwM2M self-signed" |
41 | 41 | # Client |
42 | 42 | CLIENT_STORE=clientKeyStore1.jks |
43 | 43 | CLIENT_STORE_PWD=client_ks_password1 |
44 | -CLIENT_ALIAS=client_alias_1 | |
45 | -CLIENT_PREFIX=LwX509_ | |
46 | -CLIENT_SELF_ALIAS=client_self_signed | |
44 | +CLIENT_ALIAS_PREFIX=client_alias_1 | |
45 | +CLIENT_PREFIX=LwX509___ | |
46 | +CLIENT_SELF_ALIAS_PREFIX=client_self_signed_1 | |
47 | 47 | CLIENT_SELF_CN="$DOMAIN_SUFFIX client LwM2M self-signed" |
48 | 48 | |
49 | 49 | # Color output stuff | ... | ... |
... | ... | @@ -53,7 +53,7 @@ transport: |
53 | 53 | # model_path_file: "${LWM2M_MODEL_PATH_FILE:./common/transport/lwm2m/src/main/resources/models/}" |
54 | 54 | model_path_file: "${LWM2M_MODEL_PATH_FILE:}" |
55 | 55 | recommended_ciphers: "${LWM2M_RECOMMENDED_CIPHERS:false}" |
56 | - recommended_supported_groups: "${LWM2M_RECOMMENDED_SUPPORTED_GROUPS:false}" | |
56 | + recommended_supported_groups: "${LWM2M_RECOMMENDED_SUPPORTED_GROUPS:true}" | |
57 | 57 | request_pool_size: "${LWM2M_REQUEST_POOL_SIZE:100}" |
58 | 58 | request_error_pool_size: "${LWM2M_REQUEST_ERROR_POOL_SIZE:10}" |
59 | 59 | registered_pool_size: "${LWM2M_REGISTERED_POOL_SIZE:10}" |
... | ... | @@ -69,7 +69,7 @@ transport: |
69 | 69 | key_store_path_file: "${KEY_STORE_PATH_FILE:}" |
70 | 70 | key_store_password: "${LWM2M_KEYSTORE_PASSWORD_SERVER:server_ks_password}" |
71 | 71 | root_alias: "${LWM2M_SERVER_ROOT_CA:rootca}" |
72 | - enable_gen_psk_rpk: "${ENABLE_GEN_PSK_RPK:true}" | |
72 | + enable_gen_new_key_psk_rpk: "${ENABLE_GEN_NEW_KEY_PSK_RPK:false}" | |
73 | 73 | server: |
74 | 74 | id: "${LWM2M_SERVER_ID:123}" |
75 | 75 | bind_address: "${LWM2M_BIND_ADDRESS:0.0.0.0}" |
... | ... | @@ -79,9 +79,12 @@ transport: |
79 | 79 | bind_port_security: "${LWM2M_BIND_PORT_SECURITY:5686}" |
80 | 80 | # Only for RPK: Public & Private Key. If the keystore file is missing or not working |
81 | 81 | # create_rpk: "${CREATE_RPK:}" |
82 | - public_x: "${LWM2M_SERVER_PUBLIC_X:405354ea8893471d9296afbc8b020a5c6201b0bb25812a53b849d4480fa5f069}" | |
83 | - public_y: "${LWM2M_SERVER_PUBLIC_Y:30c9237e946a3a1692c1cafaa01a238a077f632c99371348337512363f28212b}" | |
84 | - private_s: "${LWM2M_SERVER_PRIVATE_S:274671fe40ce937b8a6352cf0a418e8a39e4bf0bb9bf74c910db953c20c73802}" | |
82 | + # - Public Key (Hex): [ 3059301306072a8648ce3d020106082a8648ce3d03010703420004b47a14ea87ab31cce28f24df0ae0a4cfcdb845134bcd088f2fac393b4d4843d140ebc1bfd8f5e0ec402fb8308c5c07bc380783276a385f89ef0da0b1a2545c25 ] | |
83 | + # - Private Key (Hex): [ 3041020100301306072a8648ce3d020106082a8648ce3d030107042730250201010420b65b265abfb9e67be12a7699c13123cf081c72c974688fb4faba82be129ef367 ], | |
84 | + # - Elliptic Curve parameters: [ secp256r1 [ NIST P-256, X9.62 prime256v1 ] (1.2.840.10045.3.1.7) ] | |
85 | + public_x: "${LWM2M_SERVER_PUBLIC_X:b47a14ea87ab31cce28f24df0ae0a4cfcdb845134bcd088f2fac393b4d4843d1}" | |
86 | + public_y: "${LWM2M_SERVER_PUBLIC_Y:40ebc1bfd8f5e0ec402fb8308c5c07bc380783276a385f89ef0da0b1a2545c25}" | |
87 | + private_s: "${LWM2M_SERVER_PRIVATE_S:b65b265abfb9e67be12a7699c13123cf081c72c974688fb4faba82be129ef367}" | |
85 | 88 | # Only Certificate_x509: |
86 | 89 | alias: "${LWM2M_KEYSTORE_ALIAS_SERVER:server}" |
87 | 90 | bootstrap: |
... | ... | @@ -93,9 +96,9 @@ transport: |
93 | 96 | bind_address_security: "${LWM2M_BIND_ADDRESS_BS:0.0.0.0}" |
94 | 97 | bind_port_security: "${LWM2M_BIND_PORT_SEC_BS:5688}" |
95 | 98 | # Only for RPK: Public & Private Key. If the keystore file is missing or not working |
96 | - public_x: "${LWM2M_SERVER_PUBLIC_X_BS:993ef2b698c6a9c0c1d8be78b13a9383c0854c7c7c7a504d289b403794648183}" | |
97 | - public_y: "${LWM2M_SERVER_PUBLIC_Y_BS:267412d5fc4e5ceb2257cb7fd7f76ebdac2fa9aa100afb162e990074cc0bfaa2}" | |
98 | - private_s: "${LWM2M_SERVER_PRIVATE_S_BS:9dbdbb073fc63570693a9aaf1013414e261c571f27e27fc6a8c1c2ad9347875a}" | |
99 | + public_x: "${LWM2M_SERVER_PUBLIC_X_BS:f6e4e77f76296472bd72acfb6b2dd26fd858042f9075b44b45e2ebeb41cae387}" | |
100 | + public_y: "${LWM2M_SERVER_PUBLIC_Y_BS:3e97534c6b833639f71916041b0596ecd616748d81174d19c59ef02bbb21c822}" | |
101 | + private_s: "${LWM2M_SERVER_PRIVATE_S_BS:3e97534c6b833639f71916041b0596ecd616748d81174d19c59ef02bbb21c822}" | |
99 | 102 | # Only Certificate_x509: |
100 | 103 | alias: "${LWM2M_KEYSTORE_ALIAS_BOOTSTRAP:bootstrap}" |
101 | 104 | # Redis | ... | ... |