Google app engine 生成与GCP兼容的Cloudflare SSL证书

Google app engine 生成与GCP兼容的Cloudflare SSL证书,google-app-engine,ssl,google-cloud-platform,openssl,cloudflare,Google App Engine,Ssl,Google Cloud Platform,Openssl,Cloudflare,我正在尝试为谷歌云的应用程序引擎配置SSL。 您可以在GCP中上载自己的自定义SSL证书+私钥(请参阅) 我正在将Cloudflare用于DNS,并希望在Cloudflare中使用“完整(严格)”SSL策略。这意味着我必须在GCP中添加Cloudflare创建的证书和密钥(在同一屏幕截图中) 我已成功地将私钥转换为GCP将接受的有效(PEM)格式。唯一不起作用的是证书部分 在GCP中输入证书和密钥时,单击“上载”,返回以下错误: The certificate data is invalid.

我正在尝试为谷歌云的应用程序引擎配置SSL。 您可以在GCP中上载自己的自定义SSL证书+私钥(请参阅)

我正在将Cloudflare用于DNS,并希望在Cloudflare中使用“完整(严格)”SSL策略。这意味着我必须在GCP中添加Cloudflare创建的证书和密钥(在同一屏幕截图中)

我已成功地将私钥转换为GCP将接受的有效(PEM)格式。唯一不起作用的是证书部分

在GCP中输入证书和密钥时,单击“上载”,返回以下错误:

The certificate data is invalid. Please ensure that the private key and public certificate match.
在谷歌搜索之后,我找到了以下资源,解释我需要一个完整的证书链上传到证书字段。因此,我尝试的下一件事是将我的cloudflare证书与cloudflare本身的证书合并,如GCP文档中所述。 因此,我运行以下命令来创建此链:

cat domain.crt cloudflare-root-ca.crt > concat.crt
。。。并将其上传到GCP的证书字段中

这也不起作用,即使私钥和证书链的校验和匹配为,通过运行:

openssl x509 -noout -modulus -in concat.crt | openssl md5
openssl rsa -noout -modulus -in myserver.key.pem | openssl md5
…并比较md5输出

所以现在我完全没有想法了。GCP的错误消息仅限于上述一条,另一条则表示您的PK格式无效

通过CLI(gcloud)尝试时出现相同问题 通过cli
gcloud
尝试此过程时,我们会收到相同的错误。 正在尝试以下命令:

gcloud app ssl-certificates create --display-name example.com --certificate ./cloudflare-concat.crt  --private-key cloudflare-pk.key
…产生以下错误:

ERROR: (gcloud.app.ssl-certificates.create) 
INVALID_ARGUMENT: Invalid certificate. 
`CertificateRawData` must contain a PEM encoded x.509 public key certificate, with header and footer included, 
and an unencrypted PEM encoded RSA private key, with header and footer included and with size at most 2048 bits. 
The requested private key and public certificate must match.
非常感谢在GCP中上传有效证书(来自Cloudflare)和私钥方面的任何帮助

更新1 我发现它描述了Cloudflare的所有根证书和中间证书。我已经尝试过将它们连接到我的域证书上,但到目前为止没有成功。也不清楚该用哪一个

更新2 我开始认为这是行不通的。因为我使用的是Cloudflare的“原产地证书”,所以我相信这是Cloudflare本身的自签名证书,这意味着App Engine永远不会将其识别为有效证书

我之所以这样认为,是因为我试图使用cloudflare中的
cfssl
工具来自动“创建捆绑证书”。我从跑步中得到的反应

cfssl bundle -cert domain.crt
返回以下结果:

[INFO] bundling certificate for {Country:[] Organization:[CloudFlare, Inc.] OrganizationalUnit:[CloudFlare Origin CA] Locality:[] Province:[] StreetAddress:[] PostalCode:[] SerialNumber: CommonName:CloudFlare Origin Certificate Names:[{Type:2.5.4.10 Value:CloudFlare, Inc.} {Type:2.5.4.11 Value:CloudFlare Origin CA} {Type:2.5.4.3 Value:CloudFlare Origin Certificate}] ExtraNames:[]}
{"code":1220,"message":"x509: certificate signed by unknown authority"}
额外信息
  • 我正在使用免费的Cloudflare订阅
  • 使用Cloudflare的“灵活”设置时,一切都正常工作
  • 但我想使用“完整(严格)”设置

请验证您使用的是免费Cloudflare或付费Cloudflare帐户。
因为如果你免费使用,我认为SSL strict是行不通的,那么就让它变得灵活,并将所有HTTP请求重定向到https请求。

我发现了一篇最近的博客文章,描述了如何解决这个问题。 按照所描述的步骤操作后,证书在Google Cloud中被接受,并且一切都适用于cloudflare中的“完整(严格)ssl”选项

简言之:这需要对密钥进行一些调整,如blogpost中所述,手动添加“RSA”

请参阅此链接:

编辑:
这可能与使用@Andrei

所述的shell命令的最终结果相同。请尝试使用联机ssl证书验证您正在导入的文件是否有任何问题:@JohnHanley尝试了它,一切都正常order@AndriesApp Engine现在支持Cloudflare源CA证书。感谢@Andrei的链接,与此同时,我能够根据我在下面的回答中提到的博客帖子中解释的步骤来解决这个问题。我已经更新了我的问题。我正在使用免费的cloudflare sub。但是我想使用这个免费帐户中的完全严格选项。