使用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.

相关问答

更多

R in()函数:当最后一个值为NA时出现意外错误(R within() function: unexpected error when last value(s) are NA)

在这种情况下,我倾向于使用“%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, "T...

如果数据是NA,则不绘制图表的轴?(Not plotting the axis of a chart if data is NA?)

是的,这是可能的。 您需要创建两个动态范围名称,这些名称仅扩展到包含数据的行,并使用这些范围名称作为图表轴和图表值的来源。 Debra Dalgleish已经创建了一个详细的步骤,并在Jon Peltier的网站上发布 如果您在按照文章中描述的步骤操作后遇到问题,请填写。 评论后编辑:动态范围名称的美妙之处在于,有许多方法可以构建它们,具体取决于最适合您的数据集。 如果您将日期作为标签并且图表应仅延伸到当前月份,则可以使用动态范围中的日期作为标签,并从该名称中偏移系列的范围名称。 创建这两个范围名...

大熊猫在na_values和转换器之间的read_excel干扰bug?(Pandas read_excel interference between na_values and converters bug?)

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})...

Excel 2013 - “移动到另一张表”的微型图表错误?(Excel 2013 - Miniature chart bug on “move to another sheet”?)

问题是由于PRINTER DRIVERS(!)未能应对这些“Chartsheets”而产生的。 我没有一个如何发生这种情况的线索,但如果人们遇到这样的问题,唯一能解决问题的是如果你不打印任何东西也要更换打印机。 在这种情况下我的是Microsoft XPS Document Writer,我把它改成了.pdf打印机。 The problem was generated by a failure of PRINTER DRIVERS (!) to cope with those "Chartshee...

使用= NA()时的Excel图表错误(Excel Chart Bug when using =NA())

这似乎是由于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...

R语言NaN + NA行为(R Language NaN + NA behaviour)

来自?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)....

用NA替换(replace with NA)

这可能是一个问题的两个类是字符和因素。 这应循环遍历dtaframe并将“NA”值转换为true <NA> ,但仅适用于这两个类: make.true.NA <- function(x) if(is.character(x)||is.factor(x)){ is.na(x) <- x=="NA"; x} else { x} df[] <- lapply(df, m...

rollum产生意想不到的NA(rollsum producing unexpected NA)

rollmean和rollsum的默认方法不处理包含NA的输入。 在这种情况下,请改用rollapply。 The default methods of rollmean and rollsum do not handle inputs that contain NAs. In such cases, use rollapply instead.

将NA yearqtr转换为动物园中的字符串:可能的错误?(Conversion of NA yearqtr to string in zoo: possible bug?)

谢谢你指出这个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 ...

NA在`i`表达data.table(可能的bug)[重复](NA in `i` expression of data.table (possible bug) [duplicate])

正如@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在另一个答案中指出的那样)。 相关部分是: 整...

相关文章

更多

Node.js视频教程

捷训Node.js入门教学视频,对初学者来说应该不错的,教学视频中包括javascript的基本知识的 ...

java server怎样和c++ client实现SSL通信??

java keytool生成的证书是CRT等格式的,这种格式是2进制编码的,而C++用的证书格式是pe ...

了解 https ssl数字证书,关注 GlobalSign 微信,拿优盘

本文转载自《了解 https ssl数字证书,关注 GlobalSign 微信,拿优盘》 原文地址:h ...

了解 https ssl数字证书,关注 GlobalSign 微信,拿优盘

本文转载自《了解 https ssl数字证书,关注 GlobalSign 微信,拿优盘》 原文地址:h ...

Hadoop Backup Node

要了解 Hadoop Backup Node,要从Namenode的元数据说起。 我们都知道 ...

Hadoop node 部署步骤

1.OS安装 a)RHEL 6.2 X64 i.刻录光盘安装(略) b)安装选项 i.Basic se ...

社区版Federated HDFS(多Name Node)实现浅析

目前,HDFS集群的架构包括了单个Name Node和若干个Data Node。Name Node负责 ...

Hadoop 解除 “Name node is in safe mode”

之前在 Hadoop执行过程中使用了&quot;ctrl+c&quot;操作 再次使用had ...

Hadoop 解除 “Name node is in safe mode”

运行Hadoop程序时,有时候会报以下错误: org.apache.hadoop.dfs.SafeM ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本