iosobjective-cgrpccertificate-pinning

TLS Certificate pinning in gRPC


Using the Objective-C gRPC library, how do I implement TLS certificate pinning?

Bonus question: how do I achieve this using GRPCcall2, and not the deprecated GRPCcall?


Solution

  • gRPC doesn't support TLS certificate pinning, but you can set the root certificate in GRPCMutableCallOptions

    
    /**
     * PEM format root certifications that is trusted. If set to nil, gRPC uses a list of default
     * root certificates.
     */
    @property(copy, readwrite, nullable) NSString *PEMRootCertificates;
    

    https://github.com/grpc/grpc/blob/master/src/objective-c/GRPCClient/GRPCCallOptions.h#L331