首页 \ 问答 \ 如何使用curl客户端证书身份验证上传?(How to upload with curl client certificate authentication?)

如何使用curl客户端证书身份验证上传?(How to upload with curl client certificate authentication?)

除了对上传使用基本或摘要式身份验证之外,服务是否可以生成证书以供客户端下载以进行身份​​验证的上载? 例如,可以使用Keygen ,尽管在某处“保存证书”可能更为直接。

一旦用户拥有证书,用户就可以通过cURL上传“foobar.png”。 也许是这样的:

curl -E mycert.pem -F "fileupload=@foobar.png" http://example.com/secure-upload.php

有没有人设置类似的计划? 我不确定它是否可行,因为联机帮助页中的-E开关未提及POST。 另外,我不确定如何设置httpd服务来验证证书。 希望只是一个Apache SSL指令


Instead of using basic or digest authentication for an upload, could it be possible for a service to generate a certificate for the client to download for authenticated uploads? Keygen could be used for example, though it might be more straightforward to "Save the certificate" somewhere.

Once the user has the certificate, the user is able to then upload "foobar.png" via cURL. Perhaps like so:

curl -E mycert.pem -F "fileupload=@foobar.png" http://example.com/secure-upload.php

Has anyone setup a similar scheme? I'm not sure it's possible as the -E switch in the manpage does not mention POST. Also I am unsure how to setup the httpd service to authenticate the certificate. Hopefully just an Apache SSL directive.


原文:https://stackoverflow.com/questions/909622
更新时间:2024-02-04 07:02

最满意答案

通常会将def版本编写为:

def f2(a:Int) = a+1

如果你按照自己的方式编写它,它实际上是在创建一个方法f2 ,当被调用时,构造一个新的函数闭包。 所以在你的两种情况下,你仍然有一个功能。 但在第一种情况下,函数只构造一次并存储(如f1 )供以后使用。 但在第二种情况下,每次引用f2都会构造函数,这是一种浪费。

那么什么时候比一个方法更喜欢一个函数呢? 那么,在某些情况下,您可以更轻松地使用函数。 考虑这种情况:

(1 to 3).map(f1 andThen f1)    // totally fine
(1 to 3).map(f2 andThen f1)    // "missing arguments" error
(1 to 3).map(f2 _ andThen f1)  // fixed by adding "_" after the method name

因此f1始终是一个函数,因此您可以调用类似于andThen的方法。 变量f2代表一种方法,所以它不希望像这样使用; 它总是希望跟随论证。 您可以随后通过下划线将方法转换为函数,但如果没有必要,这可能看起来有点难看。


Typically one would write the def version as:

def f2(a:Int) = a+1

If you write it they way you did, it's actually creating a method f2 that, when called, constructs a new function closure. So in both of your cases, you still have a function. But in the first case, the function gets constructed only once and stored (as f1) for later use. But in the second case, the function gets constructed every time f2 is referenced, which is kind of a waste.

So when to prefer a function over a method? Well, you can work with a function a bit more easily in certain situations. Consider this case:

(1 to 3).map(f1 andThen f1)    // totally fine
(1 to 3).map(f2 andThen f1)    // "missing arguments" error
(1 to 3).map(f2 _ andThen f1)  // fixed by adding "_" after the method name

So f1 is always a function and so you can call a method like andThen on it. The variable f2 represents a method, so it doesn't expect to be used like this; it always expects to be followed by arguments. You can always turn a method into a function by following it with an underscore, but this can look a little ugly if it's not necessary.

相关问答

更多
  • 在引擎盖下,功能和方法之间还有其他差异。 一般来说,普通方法比函数产生的开销要小(这在技术上是带有apply方法的对象)。 然而,如果你不去关心这些差异,并把def , val和var成不同语义的字段 ,那么简单的说, def每次调用时都会评估它,而val只评估一次。 因此, val isEven = isDivisibleBy(2)应在其定义期间调用isDivisibleBy(2)并分配isDivisibleBy(2)的结果。 例如,它取代了k def isDivisibleBy(k: Int): Int ...
  • 谁能解释这个签名? futureUsing[I <: Closeable, R] futureUsing使用两种不同的类型(两种类型参数)。 我们不确切地知道它们是什么类型,但是我们将调用一个I (输入),它是一个(或派生自) Closable ,另一个是R (结果)。 (resourse: I) 对于futureUsing的第一个讨论论点是I型。 我们称之为resourse 。 (f: I => Future[R]) 第二个curried参数f是一个函数,它接受类型I的参数并返回一个将最终包含R类型 ...
  • 希望我能证明发生了什么: class TheClass { def theMethod:Unit = { println("It's me the method"); } } scala> classOf[TheClass].getDeclaredMethod("theMethod").invoke(new TheClass, null) java.lang.IllegalArgumentException: wrong number of arguments at sun.reflect.N ...
  • ??? 被设计为占位符,是Predef定义的方法(默认情况下自动导入) 它的定义是 def ??? : Nothing = throw new NotImplementedError 所以它的返回类型为Nothing ,它所做的就是抛出NotImplementedError 。 此定义允许它用作您定义但尚未实现但仍希望能够编译程序的方法的占位符实现。 Nothing是每种类型的子类型,这使得??? 无论预期的类型是什么,都是有效的实现。 ??? is designed as a placeholder an ...
  • 概要: 是的,可以在Scala中测试两个具体函数引用之间的相等性,但不完全如您所说明的那样。 您只需捕获对象,类或特征(不是lambda表达式,匿名函数等)的具体函数引用。 细节: 因为Scala确实具有函数引用的概念,所以可以检查两个不同的函数引用以引用相等。 而且由于Scala还提供了一种从任何有效的Scala方法获取函数引用的机制,这意味着你可以做你正在寻找的东西,给出你对mz答案的评论问题,“......没有办法得到一个参考或类似的方法?“ 最重要的是要记住两个函数只能用于参考平等。 IOW,函数不 ...
  • 我不能告诉你你做错了什么,但我使用compiler.typedTree在我的项目中获取AST。 也许这也适用于你。 有关更多上下文,请参阅http://scala.ifs.hsr.ch/browser/src/scala/tools/refactoring/util/CompilerProvider.scala 。 I can't tell you what you're doing wrong, but I use compiler.typedTree to get an AST in my projec ...
  • 通常会将def版本编写为: def f2(a:Int) = a+1 如果你按照自己的方式编写它,它实际上是在创建一个方法f2 ,当被调用时,构造一个新的函数闭包。 所以在你的两种情况下,你仍然有一个功能。 但在第一种情况下,函数只构造一次并存储(如f1 )供以后使用。 但在第二种情况下,每次引用f2都会构造函数,这是一种浪费。 那么什么时候比一个方法更喜欢一个函数呢? 那么,在某些情况下,您可以更轻松地使用函数。 考虑这种情况: (1 to 3).map(f1 andThen f1) // tota ...
  • cons不是Stream2实例的一部分。 它是Stream2对象的单例(静态)方法。 因此,访问它的唯一方法是通过对象调用它: Stream2.cons(2,s) 要访问实例上的方法,您必须将其添加到trait (因为它引用特征而不是创建的最终对象)。 否则,您可以将其添加到单例并通过它调用它。 cons is not part of the Stream2 instance. It is a singleton(static) method of the Stream2 object. So, the ...
  • 您可以在此处使用的一般类型是GenTraversable : scala> def printAll(coll: collection.GenTraversable[_]) = coll.foreach(println) defined function printAll scala> printAll("aaa") a a a scala> printAll(Array(1,2,3)) 1 2 3 scala> printAll(Seq(4,5,6)) 4 5 6 您也不需要迭代器。 您可以更轻松地 ...
  • 这个问题引起了我的兴趣,所以我浏览了Scala代码库并查看了mapConserves()实际用途。 在一些地方弹出的一个是:如果参数是部分函数,轻松跟踪地图操作是否已经进行了实际更改(通过简单的参考检查),就像在Erasure的示例中一样: def squashBoxed(tp: Type): Type = tp.dealiasWiden match { case t @ RefinedType(parents, decls) => val parents1 = parents mapConse ...

相关文章

更多

最新问答

更多
  • 获取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的基本操作命令。。。