Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit fac126c

Browse files
DmitriyKirakosyanlucen-ms
authored andcommitted
[Service] Ignore .codepushrelease when computing package hash
This change fixes the error: CodePushInvalidUpdateException: The update contents failed the data integrity check.
1 parent 73e2067 commit fac126c

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

api/script/utils/hash-utils.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ try {
2828
import Promise = q.Promise;
2929
const HASH_ALGORITHM = "sha256";
3030

31+
const CODEPUSH_METADATA = '.codepushrelease';
32+
3133
export function generatePackageHashFromDirectory(directoryPath: string, basePath: string): Promise<string> {
3234
if (!fs.lstatSync(directoryPath).isDirectory()) {
3335
throw new Error("Not a directory. Please either create a directory, or use hashFile().");
@@ -187,7 +189,14 @@ export class PackageManifest {
187189
public computePackageHash(): Promise<string> {
188190
let entries: string[] = [];
189191
this._map.forEach((hash: string, name: string): void => {
190-
entries.push(name + ":" + hash);
192+
// .codepushrelease (relates to code signing feature) file
193+
// should not be skipped in isIgnored() method.
194+
// But to be equal with hashes computed in SDKs and CLI this file
195+
// should be skipped when computing whole package hash
196+
197+
if (name !== CODEPUSH_METADATA && !endsWith(name, '/' + CODEPUSH_METADATA)) {
198+
entries.push(name + ':' + hash);
199+
}
191200
});
192201

193202
// Make sure this list is alphabetically ordered so that other clients

cli/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,3 +772,60 @@ code-push-standalone deployment clear <appName> <deploymentName>
772772
```
773773

774774
After running this command, client devices configured to receive updates using its associated deployment key will no longer receive the updates that have been cleared. This command is irreversible, and therefore should not be used in a production deployment.
775+
776+
## Code Signing for CodePush
777+
778+
Code Signing ensures that updates deployed via CodePush are secure and verified. Follow these steps to set up Code Signing:
779+
780+
### 1. Generate a Signing Key
781+
782+
**Create private and public keys using OpenSSL:**
783+
784+
```shell
785+
# generate private RSA key and write it to private.pem file
786+
openssl genrsa -out private.pem
787+
788+
# export public key from private.pem into public.pem
789+
openssl rsa -pubout -in private.pem -out public.pem
790+
```
791+
792+
### 2. Configure CodePush CLI
793+
794+
**Specify the path to your private key when releasing updates:**
795+
796+
```shell
797+
code-push-standalone release-react <appName> <platform> --privateKeyPath private.pem
798+
```
799+
800+
### 3. Configure Your App
801+
802+
#### iOS
803+
804+
**Add the public key to your `Info.plist`:**
805+
806+
- Open your `Info.plist` file.
807+
- Add a new entry:
808+
809+
```xml
810+
<key>CodePushPublicKey</key>
811+
<string>-----BEGIN PUBLIC KEY-----
812+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...
813+
-----END PUBLIC KEY-----</string>
814+
```
815+
816+
Replace the placeholder with the actual contents of your `public.pem` file.
817+
818+
#### Android
819+
820+
**Add the public key to your `strings.xml`:**
821+
822+
- Open `res/values/strings.xml`.
823+
- Add the following entry:
824+
825+
```xml
826+
<string name="CodePushPublicKey">-----BEGIN PUBLIC KEY-----
827+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...
828+
-----END PUBLIC KEY-----</string>
829+
```
830+
831+
Replace the placeholder with the actual contents of your `public.pem` file.

0 commit comments

Comments
 (0)