All Products
Search
Document Center

:How do I improve the authentication performance when I use the HttpEndpoint operation?

Last Updated:Sep 02, 2024

Overview

When the HttpEndpoint operation is used for authentication, it is time-consuming to remotely request a public key certificate. This topic describes how to improve the authentication performance.

Background information

Each push request carries the address of the public key certificate. The certificate can be cached in a key-value pair based on the address. As long as the certificate is not updated, the certificate can be directly obtained from the memory without sending remote requests. If the certificate is replaced, the certificate name and address may be updated.

Solution

When you process a push request, directly obtain the certificate from the memory based on the address in the x-mns-signing-cert-url parameter. If you cannot obtain the certificate, remotely access and store the certificate in the memory for subsequent use.

For example, the address of the public key certificate is: https://mnstest.oss-cn-hangzhou.aliyuncs.com/x509_public_certificate.pem. Enter the following content to store the public key certificate:

typedef map<string, string> cache;
cache["x509_public_certificate.pem"] = "$content";
cache["x509_public_certificate.pem.version2"] = "$content2";