Shouldn't CSRs automatically add default version?

原文:http://openssl.6102.n7.nabble.com/Shouldn-t-CSRs-automatically-add-default-version-td44357.html
Classic List Threaded
3 messages  Options 
Ken Smith
Reply | Threaded | More     
Mar 17, 2013; 2:22am

Shouldn't CSRs automatically add default version?

3 posts
(I originally sent this to openssl-users but it is a question about 
the implementation of OpenSSL more than the usage so I'm reposting 
here.)

I'm programmatically generating CSRs per the example in 10.3.1 of 
Network Programming with OpenSSL. This CSR is fine according to the 
openssl command line tool and to Bouncy Castle's .NET PKCS#10 handling 
code. The Windows Crypto API function, CryptDecodeObjectEx refuses to 
parse the CSR claiming that it is corrupted ASN.1. Here's an example.

-----BEGIN CERTIFICATE REQUEST----- 
MIICbzCCAVcCADArMSkwJwYDVQQDEyBiYjA2NGU1MDIwMTcwOTE4MTY0ZTlmMDY2 
MWMyNmVhMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMWfPXnVtnMj 
e2WvpNuBQW7lg3cxztBbPPyis+KoWysslWjA2Z2JpKN3GY25ncpZoJWbCMetIFPA 
Ue/cqOM0IWlck9tjPOFby+Zjftz5icdaJ1+xGryX9NizyCuAFlxWlKwToH8d22sG 
xYnKK/ioRKXjZb14tyME0tA3MOXO3JN+2+KK6A0BC54GO03ce72PYpbx0FYkt9VF 
bAgc42Xq9wiNJfzH/gbyk/avFvMHNL+5pJ1oBWjbbGUiPCHqONuVmKFsGP81lNJG 
HUrK7J1cKfyfV2YR7RJZLKDXBf6UKh0Qntrpm5f5lYIgNekt/AY2DDHBoyBItjIk 
/pUWfnvXTcsCAwEAAaAAMA0GCSqGSIb3DQEBCwUAA4IBAQBse8alivTZxKF2Uw2f 
3xM84buzbrvTsMAVDpGGgkuOd54lcShMvhIMpHDmuQgDrJgRuhbLhKpcXJIpQxj9 
zZbvlZnKPuvqOQX0+4rTgl4QTq42dCOnRxSLrmuh1kZoB40bp7iICKQq3zXsz89v 
HNPC54Pnwxv1sp0J2C2EG6c3WdBJ9Z8F8yhUPdJWQla91i5rLVSrZClDm80bCpPf 
WYmmGRhyCwZ6XeD0FkvcUTxXpJkyhzYlyG7KndW0EScazJdBens8ox2YdUtpw2BT 
OYy6Bu/cFhgqdYKUxd0iVQ9lP4xrLzKYl3x0Np2Qay8n59rDhsAfgk0bSc0Lxok3 
0s8Z 
-----END CERTIFICATE REQUEST-----

OpenSSL's command line asn1parse tool reads this just fine. Peter 
Gutmann's dumpasn1 (www.cs.auckland.ac.nz/~pgut001/dumpasn1.c) claims 
that there are two ASN.1 errors in this CSR.

0 623: SEQUENCE { 
  4 343:   SEQUENCE { 
  8   0:     INTEGER 
       :       Error: Object has zero length. 
 10  43:     SEQUENCE { 
... 
349   0:     [0] 
       :       Error: Object has zero length. 
       :     } 
351  13:   SEQUENCE { 
353   9:     OBJECT IDENTIFIER '1 2 840 113549 1 1 11' 
364   0:     NULL 
       :     }

This could be an error with Mr. Gutmann's tool but the fact that 
Windows Crypto API doesn't like the CSR is curious. I followed this 
advice

http://stackoverflow.com/questions/15294964/windows-2008r2-ca-openssl-csr-error-parsing-csr-asn1-bad-value-met

and added a call to X509_REQ_set_version(req, 0). Now Windows Crypto 
API will accept CSRs I generate.

Section 4.1 of RFC 2986 says, "Certification request information shall 
have...CertificationRequestInfo ::= SEQUENCE { version INTEGER { v1(0) 
} (v1,...),". Shouldn't OpenSSL be adding a version with a default 
value of 0 even when X509_REQ_set_version is not called?

Kind regards, 
   Ken Smith 
   :{> 
______________________________________________________________________ 
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [hidden email] 
Automated List Manager                           [hidden email]

Remove Ads
Erwann ABALEA
Reply | Threaded | More     
Mar 18, 2013; 8:42pm

Re: [openssl-dev] Shouldn't CSRs automatically add default version?

221 posts
That CSR is clearly invalid, because one of its objects isn't properly 
DER encoded. 
The INTEGER encoding its version has a length equal to zero, and this 
isn't permitted by X.690 (BER/DER/CER encoding): 
"8.3.1 The encoding of an integer value shall be primitive. The contents 
octets shall consist of one or more octets."

OpenSSL could set the version to 0 by default when creating the X509_REQ 
object (this is done when you call the X509_to_X509_REQ() function). 
But the version field is not declared as "INTEGER DEFAULT v1", so it 
could be acceptable to consider that explicitely setting the version is 
the responsibility of the application creating the request.

-- 
Erwann ABALEA

Le 16/03/2013 19:22, Ken Smith a écrit :


> -----BEGIN CERTIFICATE REQUEST----- 
> MIICbzCCAVcCADArMSkwJwYDVQQDEyBiYjA2NGU1MDIwMTcwOTE4MTY0ZTlmMDY2 
> [...] 
> 0s8Z 
> -----END CERTIFICATE REQUEST----- 
> [...] 
> Section 4.1 of RFC 2986 says, "Certification request information shall 
> have...CertificationRequestInfo ::= SEQUENCE { version INTEGER { v1(0) 
> } (v1,...),". Shouldn't OpenSSL be adding a version with a default 
> value of 0 even when X509_REQ_set_version is not called?
... [show rest of quote]

______________________________________________________________________ 
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [hidden email] 
Automated List Manager                           [hidden email]

Ken Smith
Reply | Threaded | More     
Mar 19, 2013; 4:12am

Re: [openssl-dev] Shouldn't CSRs automatically add default version?

3 posts
On Mon, Mar 18, 2013 at 5:42 AM, Erwann Abalea 
<[hidden email]> wrote: 
> That CSR is clearly invalid, because one of its objects isn't properly DER 
> encoded.

This is precisely my point. All of the OpenSSL calls I make succeed 
including PEM_write_X509_REQ. Either,

- the call to PEM_write_X509_REQ should fail indicating that it can't 
construct valid ASN.1 because the structure lacks a version 
 - or the X509_REQ should encode a default version of 0 in the event 
the user failed to specify.

As it stands, it is possible to sail through successful calls to the 
OpenSSL API and end up with something invalid. This violates the the 
principle of least surprise.

:{> 
______________________________________________________________________ 
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [hidden email] 
Automated List Manager                           [hidden email]

Remove Ads
« Return to OpenSSL - Dev  |  82 views

Shouldn't CSRs automatically add default version?相关推荐

  1. Eclipse执行import命令导入maven项目时报错:Add a version or custom suffix using Name template in Advanced set...

    新建了两个maven项目在E盘workspace目录,后面移到workspace/app_engine目录下提交svn,再通过Eclipse的File->import导入时报错了: Projec ...

  2. 添加默认网关route add default gw

    如果碰到连接时,无法determine IP address,即网关无法解析地址的情况. 需要手动配置路由网关的指向.先找到网关的指向点: ifconfig里面看ppp0的destination,或者 ...

  3. Eclipse 导入Maven项目,提示Project .. already exists Add a version or custom suffix using “Name template“

    今天从svn 上检出项目至本地的Eclipse workspace 工作空间,提示如下截图错误: Project .. already exists Add a version or custom s ...

  4. Unknown version string [4.0]. Default version will be used.

    最近写了一个项目 ,项目完成要发布出现Unknown version string [4.0]. Default version will be used.问题,找了半天还以为是tomcat版本的问题 ...

  5. svn add Default@2x.png的文件含有@的文件名注意事项

    为什么80%的码农都做不了架构师?>>>    iOS的Icon里面,包含@符号 ,svn add Icon@2x.png,没法加进去. 解决的办法是,在文件名最后加一个@,例如 s ...

  6. wsl set default version: 请启用虚拟机平台 windows 功能并确保在 bios 中启用虚拟化

    ​ 前段时间电脑偶然间恢复了出厂设置,之前安装的docker之类的东西都得重来了. 既然要安装docker,肯定得用到WSL,于是就想要先把WSL的版本切换到2. 在运行了如下命令后出现了这么个问题 ...

  7. 有没有办法为Node.js项目自动构建package.json文件

    本文翻译自:Is there a way to automatically build the package.json file for Node.js projects Is package.js ...

  8. C++11中default的使用

    在C+11中,对于defaulted函数,编译器会为其自动生成默认的函数定义体,从而获得更高的代码执行效率,也可免除程序员手动定义该函数的工作量. C++的类有四类特殊成员函数,它们分别是:默认构造函 ...

  9. Linux下route add 命令加入路由列表

    route add命令的主要作用是加入静态路由,通常的格式是: route ADD 157.0.0.0 MASK 255.0.0.0  157.55.80.1 METRIC 3 IF 2 參数含义:d ...

最新文章

  1. 快速了解微信小程序的使用,一个根据小程序的框架开发的todos app
  2. 怎样快速学习html5,如何快速学习HTML5?带你了解HTML5学什么?
  3. javaweb乱码以及ajax乱码
  4. python基础单词-学习Python必背的初级单词有哪些?
  5. 全面对比 MATLAB、Julia、Python,谁在科学计算中更胜一筹?
  6. JAVA设计模式之【建造者模式】
  7. c++五子棋_Java五子棋实现
  8. vs2012打包和部署程序成可安装安装包文件(InstallShield
  9. 直击案发现场!TCP 10倍延迟的真相是?
  10. 用python编写一个求偶数阶乘的函数_一行Python代码写阶乘函数
  11. 一提开发满脸泪,不如尬评来赢书 | 张开涛亲笔签名
  12. 基于51单片机的红外计数器proteus仿真 LCD1602显示原理图程序设计
  13. 个人对计算机专业的认知
  14. php 将rgb转cmyk,将CMYK颜色值和RGB颜色相互转换的PHP代码
  15. 数据库建表语句的使用及简单实战
  16. [转帖]「白帽黑客成长记」Windows提权基本原理(上)
  17. Android自定义九宫格图案解锁
  18. java catch中throw_Java的catch块中throw e和throw new Exception(e)有什么区别?
  19. grpc进阶篇之resolver
  20. 【uniapp】解决uni.previewImage图片模糊问题

热门文章

  1. HTML5--表单标签input新增type值
  2. sqlite 统计每张表的记录数_Excel单页式人事管理表,档案记录,自带查询统计,简单实用...
  3. python 创建目录_Python虚拟环境的搭建与使用
  4. 排序算法系列:选择排序算法
  5. Oracel 修改约束命令
  6. 华为平板能运行python吗_我是如何使用华为平板的
  7. android教育游戏设计方案,基于Android平台的儿童教育游戏的设计与开发
  8. bgb邻居关系建立模型_学习开发知识图谱中的长期关系依赖
  9. 华为与思科网络产品详细比较
  10. log4jdbc oracle,通过weblogic配置log4jdbc数据源,在项目中使用该数据源,输出sql