首页 \ 问答 \ 使用cURL的HTTP GET会导致SSL错误(HTTP GET using cURL is giving SSL error)

使用cURL的HTTP GET会导致SSL错误(HTTP GET using cURL is giving SSL error)

我写了一个REST服务器,它监听8000端口。我试图用cURL命令从同一台机器调用api -

curl -H "accept: application/json" https://localhost:8000/status -v

我收到以下错误

* About to connect() to localhost port 8000 (#0)
*   Trying ::1...
* Connected to localhost (::1) port 8000 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS error -12263 (SSL_ERROR_RX_RECORD_TOO_LONG)
* SSL received a record that exceeded the maximum permissible length.
* Closing connection 0
curl: (35) SSL received a record that exceeded the maximum permissible length.

我尝试使用-k选项绕过证书验证,但无济于事。 我在这里错过了什么? 如果需要更多信息,请发表评论。

编辑 :我的朋友建议尝试在cURL命令只有HTTP。 然后绕过SSL检查,它工作。 但https有什么问题? 我是否需要为localhost安装证书? 另外,为什么没有-k选项可用?


I have written a REST server which listens on port 8000. I am trying to invoke the api from the same machine using the cURL command -

curl -H "accept: application/json" https://localhost:8000/status -v

I am getting the following error

* About to connect() to localhost port 8000 (#0)
*   Trying ::1...
* Connected to localhost (::1) port 8000 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS error -12263 (SSL_ERROR_RX_RECORD_TOO_LONG)
* SSL received a record that exceeded the maximum permissible length.
* Closing connection 0
curl: (35) SSL received a record that exceeded the maximum permissible length.

I have tried bypassing the certificate verification using -k option but to no avail. What am I missing here? Please comment if any more info is required.

EDIT: My friend suggested to try with only http in the cURL command. Then it bypassed SSL check and it worked. But whats going wrong with https? Do I need to install certificate for localhost also? Also, why didn't -k option work?


原文:https://stackoverflow.com/questions/50581099
更新时间:2023-09-07 10:09

最满意答案

@Ben Morris,谢谢你的建议。

我认为这个解决方案可以帮助其他人,我已经检查了很多论坛,在插件中添加了设计,但是我没有得到正确的解决方案,所以我在.java (从CordovaPlugin扩展)文件中实现了SurfaceView

  Context activity = this.cordova.getActivity().getApplicationContext();


  SurfaceView surfaceView = new SurfaceView(activity);
  FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT,
        Gravity.CENTER);

  cordova.getActivity().addContentView(surfaceView, params);

@Ben Morris, Thank you for your suggestion.

I think this solution may help others, I have checked lot of forums to add the design in plugin but i didn't get proper solution so i have implemented SurfaceView in the .java (Which extends from CordovaPlugin) file as bellow

  Context activity = this.cordova.getActivity().getApplicationContext();


  SurfaceView surfaceView = new SurfaceView(activity);
  FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT,
        Gravity.CENTER);

  cordova.getActivity().addContentView(surfaceView, params);

相关问答

更多
  • 尝试使用cordova plugin rm cordova-plugin-fcm --force other wise从Firebase下载google-services.json文件并将其放置在项目的根目录下,然后重试。 Try cordova plugin rm cordova-plugin-fcm --force other wise just download the google-services.json file from Firebase and place it in the root o ...
  • 要添加插件,请使用以下命令: cordova插件添加了PLUGIN_NAME 一旦添加了插件,为了调用插件代码,请在代码中注册deviceready事件并调用设备就绪事件侦听器中的插件代码。 同时确保在您的HTML中包含cordova.js文件,这会在开发时给出404错误,但是一旦您构建了Android或浏览器平台,它将包含在内,并且在执行期间它将可用。 看看这个SO发布了解更多信息。 您还可以查看此示例cordova应用程序 ,该应用程序使用本地通知插件作为插件调用的参考 To add plugin, u ...
  • 检查你的其他插件。 如果你正在使用其他插件,其中一个犯规,它可能会破坏你的cordova.js,这反过来打破了cordova.plugins。 如果您从一个全新的项目开始,只需添加该特定插件,它就可以运行。 我试过了。 所以,我的赌注是其他一些代码正在犯规,并以某种方式打破了cordova.js。 尝试使用干净的项目,并运行您的代码。 另外,仔细看看你的javascript控制台,以防其他代码无意中破坏了cordova.js。 "Phonegap App" doesn't support external ...
  • @Ben Morris,谢谢你的建议。 我认为这个解决方案可以帮助其他人,我已经检查了很多论坛,在插件中添加了设计,但是我没有得到正确的解决方案,所以我在.java (从CordovaPlugin扩展)文件中实现了SurfaceView Context activity = this.cordova.getActivity().getApplicationContext(); SurfaceView surfaceView = new SurfaceView(activity); Frame ...
  • 更新。 当我在等待回应时,我发现了一些开始做我需要的方法。 首先,我能够创建档案.csv。 $scope.criaCSV = function () { // Create Object var items = [ { name: "Item 1", color: "Green", size: "X-Large" }, { name: "Item 2", color: "Green", size: "X-Large" }, { name: " ...
  • 您的问题就像您在上一段中提到的那样,您试图在浏览器中使用Cordova插件。 这是不可能的,因为这里没有适用于您的浏览器的phonegap抽象层。 所以我认为你有一些机会: 最可靠的是每次在您的设备上部署它并在那里进行测试。 是的,我知道,如果你尝试了很多不同的想法,这总是需要几秒钟,并不是最好的。 另一种选择可能是在ngCordovaMocks创建自己的$cordovaNetwork ngCordovaMocks 。 例: angular.module('ngCordovaMocks', []) ...
  • 问题是我需要()iCloudCV插件的javascript部分。 cordova导出的模块以插件的id为前缀,因此在“fr.pierrickrouxel.cordova.plugin.iCloudKV”插件中包含“iCloudCV”变量的完整代码是: var iCloudKV = require("fr.pierrickrouxel.cordova.plugin.iCloudKV.iCloudKV"); ......然后我可以正确地引用它。 The issue is that I needed to re ...
  • 我相信你需要提供至少一个小图标。 取消注释.setSmallIcon(1)并将.setSmallIcon(1)替换为可绘制的资源ID,以用作通知中的图标。 Finally i have done some changes in building the notification object and it worked for me. try{ Log.i(TAG, "In try block of notification"); Intent intent = new In ...
  • 从这里安装最新的Nodejs: https ://nodejs.org/en/download/,安装最新的npm。 根据您正在使用的插件的repo ,该命令已被弃用。 请改用: cordova plugin add cordova-plugin-camera Install latest Nodejs from here: https://nodejs.org/en/download/ which installs latest npm. According to the repo of the plug ...
  • 对于Windows Universal,纯粹在Javascript中执行此操作是“最干净的”请参阅此https://github.com/cordova-sms/cordova-sms-plugin/issues/31 For Windows Universal, it is "cleanest" to do this purely in Javascript see this https://github.com/cordova-sms/cordova-sms-plugin/issues/31

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。