首页 \ 问答 \ 使用node.js设置SSL(Setting up SSL with node.js)

使用node.js设置SSL(Setting up SSL with node.js)

我在GoDaddy购买了SSL证书,我正在使用以下node.js服务器来尝试设置它:

var https = require('https'),      // module for https
    fs =    require('fs');         // required to read certs and keys

var options = {
    key: fs.readFileSync('../../ssl/example.com.key'),
    cert: fs.readFileSync('../../ssl/example.com.crt'),
    ca: fs.readFileSync('../../ssl/gd_bundle.crt'),
    requestCert:        true,
    rejectUnauthorized: false
};

https.createServer(options, function (req, res) {
    if (req.client.authorized) {
        res.writeHead(200, {"Content-Type": "application/json"});
        res.end('{"status":"approved"}');
    } else {
        res.writeHead(401, {"Content-Type": "application/json"});
        res.end('{"status":"denied"}');
    }
}).listen(443);

运行服务器后,我试图访问https://example.com网站,我就得到了

{"status":"denied"}

我想这是正常的,因为我得到了回复,但我认为我对SSL如何工作的理解是错误的。 我认为浏览器从服务器获取证书,然后根据根证书(即GoDaddy)对其进行身份验证。 所以我不应该得到

{"status":"approved"}

只需访问https://example.com

所以我想我的问题是,如何访问https://example.com并获取{“status”:“approved”}?

谢谢!


I bought an SSL certificate at GoDaddy and I'm using the following node.js server to attempt to set it up:

var https = require('https'),      // module for https
    fs =    require('fs');         // required to read certs and keys

var options = {
    key: fs.readFileSync('../../ssl/example.com.key'),
    cert: fs.readFileSync('../../ssl/example.com.crt'),
    ca: fs.readFileSync('../../ssl/gd_bundle.crt'),
    requestCert:        true,
    rejectUnauthorized: false
};

https.createServer(options, function (req, res) {
    if (req.client.authorized) {
        res.writeHead(200, {"Content-Type": "application/json"});
        res.end('{"status":"approved"}');
    } else {
        res.writeHead(401, {"Content-Type": "application/json"});
        res.end('{"status":"denied"}');
    }
}).listen(443);

After running the server, I attempted to visit the website at https://example.com and I just get

{"status":"denied"}

I guess this is working properly since I'm getting a response, but I think my understanding of how SSL works is wrong. I thought the browser gets the certificate from the server, which then authenticates it against root certs, i.e. from GoDaddy. so shouldn't i get

{"status":"approved"}

just simply visiting https://example.com ?

So I guess my question is, how do I visit https://example.com and get {"status":"approved"}?

Thanks!


原文:https://stackoverflow.com/questions/11804168
更新时间:2023-01-17 06:01

最满意答案

这似乎是由于Excel处理“空”单元格的方式。 似乎没有办法返回一个正确的空单元格,但之前已经讨论过不同的解决方法:

从Excel中的公式返回空单元格


Using a filter to select all data points that should be hidden and then deleting the contents of the cell works.

As I have lots of charts to do this to I was able to implement the "filter and delete" process using .Autofilter and .ClearContents methods.

相关问答

更多
  • 在这种情况下,我倾向于使用“%in%”; 它更好地处理NAs: fooTest <- data.frame(Group = c("Shell", NA, "Cup", NA, NA), CupComposition = c("Metal", NA, "Polyethylene", NA, "Test"), LinerComposition = c("Polyethylene", NA, NA, NA, "Test") ...
  • 是的,这是可能的。 您需要创建两个动态范围名称,这些名称仅扩展到包含数据的行,并使用这些范围名称作为图表轴和图表值的来源。 Debra Dalgleish已经创建了一个详细的步骤,并在Jon Peltier的网站上发布 如果您在按照文章中描述的步骤操作后遇到问题,请填写。 评论后编辑:动态范围名称的美妙之处在于,有许多方法可以构建它们,具体取决于最适合您的数据集。 如果您将日期作为标签并且图表应仅延伸到当前月份,则可以使用动态范围中的日期作为标签,并从该名称中偏移系列的范围名称。 创建这两个范围名称: ch ...
  • converters在应用na_values之前运行,这就是您看到此行为的原因。 只需在转换器中添加条件以捕获weights的...实例 - 例如添加手动滚动的na_values : df = pd.read_excel("test.xls", na_values="...", converters={"weight":lambda w: w*1000 if isinstance(w, int) else None}) pri ...
  • 问题是由于PRINTER DRIVERS(!)未能应对这些“Chartsheets”而产生的。 我没有一个如何发生这种情况的线索,但如果人们遇到这样的问题,唯一能解决问题的是如果你不打印任何东西也要更换打印机。 在这种情况下我的是Microsoft XPS Document Writer,我把它改成了.pdf打印机。 The problem was generated by a failure of PRINTER DRIVERS (!) to cope with those "Chartsheets". ...
  • 这似乎是由于Excel处理“空”单元格的方式。 似乎没有办法返回一个正确的空单元格,但之前已经讨论过不同的解决方法: 从Excel中的公式返回空单元格 Using a filter to select all data points that should be hidden and then deleting the contents of the cell works. As I have lots of charts to do this to I was able to implement the ...
  • 来自?NaN : 涉及NaN计算将返回NaN或NA :这两者中的哪一个不能得到保证并且可能依赖于R平台(因为编译器可能重新排序计算)。 From ?NaN: Computations involving NaN will return NaN or perhaps NA: which of those two is not guaranteed and may depend on the R platform (since compilers may re-order computations).
  • 这可能是一个问题的两个类是字符和因素。 这应循环遍历dtaframe并将“NA”值转换为true ,但仅适用于这两个类: make.true.NA <- function(x) if(is.character(x)||is.factor(x)){ is.na(x) <- x=="NA"; x} else { x} df[] <- lapply(df, make.t ...
  • rollmean和rollsum的默认方法不处理包含NA的输入。 在这种情况下,请改用rollapply。 The default methods of rollmean and rollsum do not handle inputs that contain NAs. In such cases, use rollapply instead.
  • 谢谢你指出这个bug。 是的,报告此类问题的最简单方法是通过电子邮件发送给维护者(=我)。 我刚刚在R-Forge的zoo开发版本(1.8-0)中解决了这个问题。 运行install.packages("zoo", repos="http://R-Forge.R-project.org")您应该得到预期的行为: library("zoo") qq <- as.yearqtr(c("2015 Q1", NA)) as.character(qq) ## [1] "2015 Q1" NA is.na ...
  • 正如@flodel指出的那样,问题可以简化为,为什么这不是TRUE : identical(x[as.logical(a)], x[!!as.logical(a)]) # note the double bangs 答案在于data.table如何处理i NA以及它如何处理! 在i 两者都接受特殊待遇。 问题确实出现在两者的结合中。 NA中的i被视为FALSE 。 ! 在i被视为否定。 这在?.data.table (正如?.data.table在另一个答案中指出的那样)。 相关部分是: 整数和逻辑向 ...

相关文章

更多

最新问答

更多
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • linux的常用命令干什么用的
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • Java中的不可变类(Immutable class in Java)
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • 绑定属性设置器未被调用(Bound Property Setter not getting Called)
  • linux ubuntu14.04版没有那个文件或目录
  • 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
  • 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
  • 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
  • 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
  • 如何按部门显示报告(How to display a report by Department wise)
  • Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
  • Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
  • WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)