如何使用SDK使用-dot-语法为SSL获取适当的App Engine模块主机名? [英] How do I obtain proper App Engine module hostname using -dot- syntax for SSL using the SDK?
问题描述
根据 App Engine上的文档,使用appspot时.com域名,你必须在子域名中使用 -dot -
而不是。
进行欺骗。
According to the docs on App Engine, when using the appspot.com domain you have to do some trickery with -dot-
instead of .
in subdomains.
请注意,2013年4月,Google停止为托管于appspot.com的双通配域名颁发SSL
证书(即
.appspot.com的)。如果您依赖此类URL来访问应用程序的HTTPS,请更改任何应用程序逻辑以使用-dot-
而不是。。例如,要访问应用程序
myapp的版本1,请使用 https:// 1 -dot-myapp.appspot.com 而不是
https://1.myapp .appspot.com的。如果您继续使用
https://1.myapp.appspot.com 证书不匹配,其中
将导致任何期望URL和
证书完全匹配的用户代理发生错误。
Please note that in April of 2013, Google stopped issuing SSL certificates for double-wildcard domains hosted at appspot.com (i.e. ..appspot.com). If you rely on such URLs for HTTPS access to your application, please change any application logic to use "-dot-" instead of ".". For example, to access version "1" of application "myapp" use "https://1-dot-myapp.appspot.com" instead of "https://1.myapp.appspot.com." If you continue to use "https://1.myapp.appspot.com" the certificate will not match, which will result in an error for any User-Agent that expects the URL and certificate to match exactly.
我正试图找出使用SDK生成这些网址而无需手动更换点的最佳方法。我试过 modules.get_hostname(module =我的模块名称)
,但它返回一个触发SSL不匹配错误的传统子域。
I am trying to figure out the best way to generate these URLs using the SDK without manually replacing the dots. I've tried modules.get_hostname(module="my module name")
but it returns a traditional sub-domain that triggers the SSL mismatch error.
Edit Per suggestion, I opened a feature request for this functionality
推荐答案
举例来说
x = 'https://1.amodule.myapp.appspot.com'
您需要用 -dot -
来替换,但最后两个点因为 .appspot.com
部分保持原样),所以最后两个必须保持不变。
you need to replace all but the last two dots with -dot-
(the last two must remain since the .appspot.com
part much stay untouched).
推荐:
Given this, I'd recommend:
>>> x = 'https://1.amodule.myapp.appspot.com'
>>> dots = x.count('.')
>>> x.replace('.', '-dot-', dots - 2)
'https://1-dot-amodule-dot-myapp.appspot.com'
主要思想: x.count('。')
告诉你有多少个点在所有字符串 x
contains; x.replace
的第三个可选参数告诉Python 最多需要替换多少个个点。
The key ideas: x.count('.')
tells you how many dots in all string x
contains; the third optional argument to x.replace
tells Python how many dots, at most, are to be replaced.
这篇关于如何使用SDK使用-dot-语法为SSL获取适当的App Engine模块主机名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!