小编fas*_*tos的帖子

Node.js - HTTPS PFX错误:无法加载BIO

我正在尝试制作HTTPS请求承诺.我已经知道PFX很好,这不是问题(我有一个类似的示例应用程序工作).

我正在做以下事情:

var request = require('request-promise');
Run Code Online (Sandbox Code Playgroud)

...

options.pfx = fs.readFileSync('myfile.pfx');
options.passphrase = 'passphrase';
Run Code Online (Sandbox Code Playgroud)

我正在将我的选项传递给请求.

request.post(options);
Run Code Online (Sandbox Code Playgroud)

然后我尝试构建请求,我收到以下错误:

_tls_common.js:130
  c.context.loadPKCS12(pfx, passphrase);
            ^

Error: Unable to load BIO
at Error (native)
at Object.createSecureContext (_tls_common.js:130:17)
at Object.exports.connect (_tls_wrap.js:955:21)
at Agent.createConnection (https.js:73:22)
at Agent.createSocket (_http_agent.js:174:16)
at Agent.addRequest (_http_agent.js:143:23)
at new ClientRequest (_http_client.js:133:16)
at Object.exports.request (http.js:31:10)
at Object.exports.request (https.js:163:15)
at Request.start (/Users/filomeno/workspace/sla-crawler/node_modules/request/request.js:747:30)
at Request.write (/Users/filomeno/workspace/sla-crawler/node_modules/request/request.js:1369:10)
at end (/Users/filomeno/workspace/sla-crawler/node_modules/request/request.js:561:16)
at Immediate._onImmediate (/Users/filomeno/workspace/sla-crawler/node_modules/request/request.js:589:7)
at processImmediate [as _immediateCallback] (timers.js:374:17)
Run Code Online (Sandbox Code Playgroud)

我有一个示例应用程序,其中相同的代码工作.我试图转换为.p12但没有成功.

有谁知道这个错误可能指的是什么?

编辑:我正在使用lodash将2个对象与dinamic属性和静态属性合并

_.merge(options, _this.requestOptions);
Run Code Online (Sandbox Code Playgroud)

这导致了问题

javascript ssl https pfx node.js

6
推荐指数
1
解决办法
881
查看次数

Rails 4 - 带有accepts_nested_attributes_for控制器设置的嵌套表单?

我正在尝试使用form_for和制作嵌套表单fields_for.经过大量的研究和成功,不再在我的项目上工作了.我只是想重新创建一个railscast,看看我做错了什么.

我正在尝试重新创建在http://railscasts.com/episodes/196-nested-model-form-part-1上找到的示例,因为代码存在,所以不应该那么难,但我可以'设法从调查中创建问题.这是我的代码,直到现在:

rails new surveysays
rails g scaffold survey name:string
rake db:migrate
rails g scaffold question survey_id:integer content:text
rake db:migrate
Run Code Online (Sandbox Code Playgroud)

我正在尝试以完全相同的视频序列进行操作.我的问题模型:

class Question < ActiveRecord::Base
  belongs_to :survey
end
Run Code Online (Sandbox Code Playgroud)

我的调查模型:

class Survey < ActiveRecord::Base
  has_many :questions, dependent: :destroy
  accepts_nested_attributes_for :questions
end
Run Code Online (Sandbox Code Playgroud)

我的调查表格带有嵌套问题字段:

<%= form_for(@survey) do |f| %>
      ...
      <div class="field">
        <%= f.label :name %><br>
        <%= f.text_field :name %>
      </div>
      <%= f.fields_for :questions do |builder| %>
        <p>
          <%= builder.label :content, "Question" %><br/>
          <%= builder.text_area :content, :row …
Run Code Online (Sandbox Code Playgroud)

controller nested-forms nested-attributes ruby-on-rails-4

4
推荐指数
1
解决办法
1万
查看次数