Mini Program package signature verification

更新时间:
复制 MD 格式

This topic describes how to enable and disable mini program package verification. By default, signature verification is enabled. You can call the API operation to modify whether signature verification is required on the endpoint.

Interface Description

@interface MPNebulaAdapterInterface : NSObject

/**
Whether to verify the signature of offline packages, the default is YES, that is, the Nebula container verifies the signature of downloaded offline packages by default. If you need to turn off signature verification during debugging, set this property to NO.
 */
@property (nonatomic, assign) BOOL nebulaNeedVerify;

/**
The public key path for offline package signature verification, the default is nil. If the offline package signature verification switch is YES, the corresponding public key must be set here, otherwise the local signature verification fails and the offline package loading fails.
 */
@property (nonatomic, strong) NSString *nebulaPublicKeyPath;

Enable a mini program signature verification

  • Turn on the switch of signature verification

    [MPNebulaAdapterInterface shareInstance].nebulaNeedVerify = YES;
  • Configure a public key for signature verification

    NSString *path = [[NSBundle mainBundle].bundlePath stringByAppendingFormat:@"%@", @"public_pem.html"];
    [MPNebulaAdapterInterface shareInstance].nebulaPublicKeyPath = path;
Note

Call the MPNebulaAdapterInterface interface before you open the mini program package for the first time. Otherwise, the public key fails to be initialized. For more information about the public and private keys, see Configure Mini Program Package.

Disable mini program signature verification

Sample code

[MPNebulaAdapterInterface shareInstance].nebulaNeedVerify = NO;