You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -2990,6 +2991,46 @@ If the `address` is provided, then `UserAddress` contains the following properti
2990
2991
Be aware that all properties in the `UserInfo` and `UserAddress` objects are optional and the availability of information depends on actual implementation on the server.
2991
2992
<!-- end -->
2992
2993
2994
+
### Creating Certificate Signing Request
2995
+
2996
+
The PowerAuth SDK can create a Certificate Signing Request (CSR) that can be used to request an X.509 certificate from a Public Key Infrastructure (PKI).
2997
+
The CSR contains a public key generated by the SDK and is signed with the activation-bound private key.
2998
+
2999
+
The created CSR in the PEM format (including `-----BEGIN CERTIFICATE REQUEST-----` and `-----END CERTIFICATE REQUEST-----` lines and newlines `\n`).
3000
+
3001
+
To create a CSR, use the following code:
3002
+
3003
+
```kotlin
3004
+
// Assume this is your PowerAuthSDK instance
3005
+
// The instance must have a valid and active activation
3006
+
val powerAuth:PowerAuthSDK!!
3007
+
3008
+
val authentication =PowerAuthAuthentication.possessionWithPassword("1111") // assume this is your password
@@ -2240,6 +2241,45 @@ If the `address` is provided, then `PowerAuthUserAddress` contains the following
2240
2241
Be aware that all properties in the `PowerAuthUserInfo` and `PowerAuthUserAddress` objects are optional and the availability of information depends on actual implementation on the server.
2241
2242
<!-- end -->
2242
2243
2244
+
### Creating Certificate Signing Request
2245
+
2246
+
The PowerAuth SDK can create a Certificate Signing Request (CSR) that can be used to request an X.509 certificate from a Public Key Infrastructure (PKI).
2247
+
The CSR contains a public key generated by the SDK and is signed with the activation-bound private key.
2248
+
2249
+
The created CSR in the PEM format (including `-----BEGIN CERTIFICATE REQUEST-----` and `-----END CERTIFICATE REQUEST-----` lines and newlines `\n`).
2250
+
2251
+
To create a CSR, use the following code:
2252
+
2253
+
```swift
2254
+
// Assume this is your PowerAuthSDK instance
2255
+
// The instance must have a valid and active activation
2256
+
let powerAuth: PowerAuthSDK!
2257
+
2258
+
let password = PowerAuthCorePassword(string: "1234") // assume this is your password
2259
+
let authentication = PowerAuthAuthentication.possessionWithPassword(password: password)
subjectAltNames: [ // subject's alternative names (SAN)
2269
+
"IP: 192.168.1.10",
2270
+
"email: admin@example.com"
2271
+
]
2272
+
) { csr, error in
2273
+
2274
+
if let csr {
2275
+
print("CSR: \(csr)")
2276
+
// Use the CSR
2277
+
} else {
2278
+
// Handle error
2279
+
}
2280
+
}
2281
+
```
2282
+
2243
2283
### Password Strength Indicator
2244
2284
2245
2285
Choosing a weak passphrase in applications with high-security demands can be potentially dangerous. You can use our [Wultra Passphrase Meter](https://github.com/wultra/passphrase-meter) library to estimate the strength of the passphrase and warn the user when he tries to use such a passphrase in your application.
Creates X.509 CSR (Certificate Signing Request) with given Distinguished Names and optional Subject Alternative Names, embedded device public key and signed with the device private key.
450
+
451
+
You have to provide at keys.userPassword and keys.possessionUnlockKey.
452
+
453
+
454
+
Returns EC_Ok if operation succeeded
455
+
EC_Encryption if general encryption error occurs
456
+
EC_WrongState if the session has no valid activation
457
+
EC_WrongParam if some required parameter is missing
* Creates X.509 CSR (Certificate Signing Request) with given Distinguished Names and optional Subject Alternative Names, embedded device public key and signed with the device private key.
488
+
* <p>
489
+
* You have to provide encrypted vault key |cVaultKey| in Base64 format and |unlockKeys| object where the valid userPassword is set.
490
+
*
491
+
* <h2>Discussion</h2>
492
+
*
493
+
* The session's state contains device private key but it is encrypted with a vault key, which is normally not
494
+
* available on the device. Just like other vault related operations, you have to properly sign HTTP request
495
+
* with using PA2SignatureFactor_PrepareForVaultUnlock flag, otherwise the operation will fail.
496
+
*
497
+
* @param cVaultKey encrypted vault key
498
+
* @param unlockKeys unlock keys object with required possession factor
499
+
* @param distinguishedNames Distinguished Names (DN) to be embedded in the CSR.
500
+
* @param subjectAltNames Subject Alternative Names (SAN)
501
+
*
502
+
* @return Returns CSR in PEM format or null in case of failure.
503
+
*/
504
+
publicStringcreatePrivateKeySignedCSR(
505
+
@NonNullStringcVaultKey,
506
+
@NonNullSignatureUnlockKeysunlockKeys,
507
+
@NonNullMap<String, String> distinguishedNames,
508
+
@NullableString[] subjectAltNames) {
509
+
510
+
ArrayList<String> dnKeys = newArrayList<>();
511
+
ArrayList<String> dnValues = newArrayList<>();
512
+
for (Map.Entry<String, String> entry : distinguishedNames.entrySet()) {
Copy file name to clipboardExpand all lines: proj-android/PowerAuthLibrary/src/main/java/io/getlime/security/powerauth/sdk/PowerAuthSDK.java
+57Lines changed: 57 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -2348,6 +2348,63 @@ public void onDataSignedFailed(@NonNull Throwable t) {
2348
2348
});
2349
2349
}
2350
2350
2351
+
/**
2352
+
* Creates X.509 CSR (Certificate Signing Request) with given Distinguished Names and optional Subject Alternative Names, embedded device public key and signed with the device private key.
2353
+
* <p>
2354
+
* This method calls PowerAuth Standard RESTful API endpoint '/pa/vault/unlock' to obtain the vault encryption key used for private recovery data decryption.
2355
+
*
2356
+
* @param context Android context.
2357
+
* @param authentication Authentication object that must contain the possession and password factor.
2358
+
* @param distinguishedNames Distinguished Names (DN) to be embedded in the CSR. The dictionary keys are DN types (like "CN", "O", etc.) and values are corresponding DN values.
2359
+
* @param subjectAltNames Optional array of Subject Alternative Names (SAN)
2360
+
* @param listener Listener with the callback methods. CSR in PEM format with lines separated by `\n` (including `-----BEGIN CERTIFICATE REQUEST`----- and `-----END CERTIFICATE REQUEST-----` lines) is returned in case of success.
2361
+
* @return {@link ICancelable} object associated with the underlying HTTP request.
/** Creates X.509 CSR (Certificate Signing Request) with given Distinguished Names and optional Subject Alternative Names, embedded device public key and signed with the device private key.
554
+
555
+
This method calls PowerAuth Standard RESTful API endpoint '/pa/vault/unlock' to obtain the vault encryption key used for private recovery data decryption.
556
+
557
+
@param authentication Authentication used for vault unlocking call.
558
+
@param distinguishedNames Distinguished Names (DN) to be embedded in the CSR. The dictionary keys are DN types (like "CN", "O", etc.) and values are corresponding DN values.
559
+
@param subjectAltNames Optional array of Subject Alternative Names (SAN)
560
+
@param callback The callback method with the CSR in PEM format with lines separated by `\n` (including `-----BEGIN CERTIFICATE REQUEST`----- and `-----END CERTIFICATE REQUEST-----` lines).
561
+
@return PowerAuthOperationTask associated with the running request.
0 commit comments