首页 \ 问答 \ Tomcat / JKS / Keytool - 重新生成私钥?(Tomcat / JKS / Keytool - regenerate private key?)

Tomcat / JKS / Keytool - 重新生成私钥?(Tomcat / JKS / Keytool - regenerate private key?)

是否可以使用keytool或等效工具在.JKS密钥库中重新生成私钥?

我已经获得了证书和JKS密钥库,但是在导入证书时,看起来已经删除了用于生成CSR的私钥。

我可以看到如何使用新的私钥创建新的密钥库,但这不会与CSR或证书匹配。


Is it possible to regenerate a private key in a .JKS keystore using keytool or equivalent?

I've been supplied with a certificate and a JKS keystore, but on importing the cert it looks like the private key that was used to generate the CSR has been deleted.

I can see how to create a new keystore with a new private key, but this won't then match the CSR or certificate.


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

最满意答案

您只需在编译时使用注释。 如果注释类在运行时不可用,则它们将不存在。

例如,如果客户端代码在域模型类上调用AnnotatedElement.getAnnotations(),并且编译的注释在类路径中不可用,则不会返回它们。

如果使用maven,则应声明注释依赖项,并使用scope可选。 可选的依赖项不会包含在客户端中。 因此,只有客户声明它们时才可用。

例如:

如果Proj-A在Proj-B上有可选的依赖项(? - >)

 Proj-A ?-> Proj-B 

并且Proj-X将Proj-A引用为编译依赖项,它将不会获得可选的依赖项Proj-B。

 Proj-X -> Proj-A 

因为传递依赖性解析以可选依赖关系结束。

期望在名为annotations.jar的jar文件中包含以下annotations.jar

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ARuntimeAnnotation {

}

并且你有一个model.jar包含的以下模型类

@ARuntimeAnnotation
public class Model {

}

并且model.jarmodel.jar有依赖关系,因为它需要它来编译。

<depdendency>
       <groupId>someGroup</groupId>
       <artifactId>annotations</artifactId>
       <scope>optional</scope>
 </dependency>

如果此依赖项是可选的,那么它将不会自动成为某人的传递依赖关系,它仅依赖于model.jar

现在客户想要使用Model类。 因此它对model.jar有依赖性。

 <depdendency>
       <groupId>someGroup</groupId>
       <artifactId>model</artifactId>
 </dependency>

如果客户端还想要查看注释ARuntimeAnnotation那么它还必须包含annotations.jar作为依赖项,因为它是可选的。

如果客户端不包含对annotations.jar的依赖,则以下调用将返回一个空数组:

 Model.class.getAnnotations(); // will be empty if the annotations.jar is not available at runtime

You only have to use the annotations at compile time. If the annotation classes are not available at runtime they will simply not exist.

E.g. if the client code calls AnnotatedElement.getAnnotations() on a domain model class and the annotations it was compiled with are not available in the class path they will not be returned.

If you use maven you should declare the annotation dependencies with scope optional. Optional dependencies will not be included in the client. Thus they are only available if the client declares them.

For example:

If Proj-A has a optional dependency ( ?-> ) on Proj-B

 Proj-A ?-> Proj-B 

and a Proj-X references Proj-A as a compile dependency it will not get the optional dependency Proj-B.

 Proj-X -> Proj-A 

because transitive dependency resolution ends on an optional dependency.

Expect that you have the following annotation in a jar file called annotations.jar

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ARuntimeAnnotation {

}

and you have the following model class contained in a model.jar

@ARuntimeAnnotation
public class Model {

}

and the model.jar has a dependency to the annotations.jar because it needs it to compile.

<depdendency>
       <groupId>someGroup</groupId>
       <artifactId>annotations</artifactId>
       <scope>optional</scope>
 </dependency>

If this dependency is optional it will not be automatically become a transitive dependency of someone how only has a dependency on the model.jar.

Now a client wants to use the Model class. Thus it has a dependency to model.jar.

 <depdendency>
       <groupId>someGroup</groupId>
       <artifactId>model</artifactId>
 </dependency>

If the client also wants to see the annotation ARuntimeAnnotation it must also include the annotations.jar as a dependency, because it is optional.

If the client does not include dependency on the annotations.jar the following call will return an empty array:

 Model.class.getAnnotations(); // will be empty if the annotations.jar is not available at runtime

相关问答

更多
  • 我找到的最佳选择是等待。 GWT团队仍在开展客户端验证工作,并将于今年夏天结束。 http://code.google.com/p/google-web-toolkit/wiki/BeanValidation 评论由项目成员ncha ... @ google.com,2012年4月10日: “我计划今年夏天完成规范的实施。” 由于这个应用程序没有太多的输入数据,我选择仅在服务器上进行验证。 Best option that I've found is to wait. GWT team is still w ...
  • 是。 Hibernate工具是一个eclipse插件,它具有可视化实体结构及其之间关系的功能。 Yes. Hibernate tool is an eclipse plug-in that has a feature to visualize the structure of entities and the relationships between them.
  • 您只需在编译时使用注释。 如果注释类在运行时不可用,则它们将不存在。 例如,如果客户端代码在域模型类上调用AnnotatedElement.getAnnotations(),并且编译的注释在类路径中不可用,则不会返回它们。 如果使用maven,则应声明注释依赖项,并使用scope可选。 可选的依赖项不会包含在客户端中。 因此,只有客户声明它们时才可用。 例如: 如果Proj-A在Proj-B上有可选的依赖项(? - >) Proj-A ?-> Proj-B 并且Proj-X将Proj-A引用为编译依赖 ...
  • 我发现总是有效的实体而不是依赖外部验证对象会更好。 话虽这么说,唯一的检查有点例外,因为它通常不是聚合本身可以自己确定的东西,你必须查看所有现有的聚合以查看该值是否尚未被采用。 我所做的是在创建实体之前检查值的可用性,并在数据库中放置一个约束,该约束将在持久性时验证唯一性。 您还可以尝试查找包含所有实体的域概念,并使其成为具有所有代码列表的聚合,并强制执行唯一性不变量。 I find it better to have always valid entities rather than rely on an ...
  • 矮小的回答:不,他们不一样。 域对象实际上是(删除) ..看看@meze的评论..有一个链接。 这部分“实体方案,它们的属性和关系”与数据结构有点相关。 但是你的Domain对象不应该知道它们被存储的事实,或者甚至存在存储。 这是数据访问层的责任。 而域模型是操纵不同类型和数量的域对象的总体结构。 Shorty answer: no, they are not the same. Domain objects actually are (removed) .. look at the comment fro ...
  • 像这样考虑一下; OOP的一个关键组成部分是关注点; 对数据进行操作的方法应与该数据分组。 通常,域模型将捕获问题域,但由于问题域“怪癖”,域模型可能无法反映关注的适当聚类。 面向对象的域建模只是将域模型重新映射到面向对象(即关注群集)模型。 他们捕获相同的东西你是对的,但关键是域模型更关注纯粹代表问题域; OODM关注的是以反映适当OOP技术的方式表示问题域。 Consider it like this; one critical component of OOP is the clustering of ...
  • 以下是有关逻辑模型和域模型的维基百科文章。 根据我的阅读,逻辑模型涉及数据对象建模和数据对象之间的关系,无需任何数据库考虑。 域模型涉及对流程建模和流程之间的关系,而不考虑任何计算机语言。 我通常使用单个逻辑/域模型用于两个目的。 第一个是为我的物理数据模型建立一个起点。 另一种是在我的业务层中映射我的类。 您的业务对象类不必与您的数据模型匹配。 例如,您可能有一个Person类,它在关系数据库上映射到几个不同的表; 人,地址,电话号码等 Here are the Wikipedia articles on ...
  • 如果验证规则构成业务域的一部分,则它们属于模型。 一个聚合根负责维护它所包含的不变量,因此验证它们属于它的责任范围。 如果您发现验证规则非常复杂,则可以创建验证服务,该验证服务将由聚合根用于此功能。 If the validation rules form part of the business domain, they belong in the model. An aggregate root is responsible of maintaining the invariants encompass ...
  • 你可以使用hibernate-tools.jar中的hbm2java ant任务。 这是一个称为Hibernate Tool的工具。 hbm2java将从hbm文件生成JPA注释的POJOS。 请参阅http://www.hibernate.org/hib_docs/tools/reference/en/html/ant.html You could use hbm2java ant task from hibernate-tools.jar. This is a tool known as Hiberna ...
  • 它由代码展出,其中: 大多数代码都以域对象(例如Account或TransactionEntity)的形式处理传递数据结构(如果你愿意的话,属性包)。 它们是“域对象”主要是因为它们具有域中存在的东西的名称。 大多数逻辑都驻留在外部“服务”中 - 包含在(或单个)数据结构列表上运行的脚本。 因此,服务需要访问/修改域对象的内部信息。因此域对象会自发地生成大量的getter和setter。 RIP封装。 贫血是指域类中域逻辑/行为的缺失或缺乏。 更多指标: 'Ask'方法超过'Tell / Do'方法 It ...

相关文章

更多

最新问答

更多
  • 以编程方式创建视频?(Create videos programmatically?)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • javascript数组,如何改变这个数组结构(javascript arrays, how to change this array structure)
  • 在ASP.NET Web API中使用多个Get方法进行路由(Routing with multiple Get methods in ASP.NET Web API)
  • 用于backbone.js验证的自定义验证器(Custom validator for backbone.js validation)
  • const char *与其他指针有什么不同?(Is const char * different from other pointers? [duplicate])
  • 无效的列索引,使用PreparedStatement更新(Invalid column index , update using PreparedStatement)
  • watchOS WCSession'已配对'和'watchAppAvailable'不可用(watchOS WCSession 'paired' and 'watchAppAvailable' are unavailable)
  • CalledFromWrongThreadException在Android上执行JUnit测试(CalledFromWrongThreadException exercising JUnit tests on Android)
  • 如何把文件保存到你的应用程序目录中?(How to put\save files into your application directory? (adobe air))
  • 美元符号在Java方法描述符中的含义?(Meanings of dollar sign in Java method descriptor?)
  • font-size的含义是什么:1em / 2em?(What doe the meaning of font-size:1em/2em?)
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • Android - 检测与特定wifi ssid断开连接的正确方法?(Android - Correct way to detect disconnecting from a particular wifi ssid?)
  • 通过Shell脚本将文件转换为另一个文件(Convert File To Another File By Shell Script)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • 如何过滤magento废弃的购物车报告集合(How to Filter the magento abandoned cart report collection)
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • web api http post传递对象504接收失败(web api http post passing object 504 Receive Failure)
  • Rails从视图编辑模型上的多个属性的方法(Rails way to edit multiple attributes on a model from a view)
  • 总是用{}初始化对象是否是好习惯?(Is it good habit to always initialize objects with {}?)
  • 在方案中编写特殊字符到输出端口(编译器设计)(writing special characters to output port in scheme (compiler design))
  • 电脑等级考试得证有多大用处?
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • 第一次调用函数将无法按预期工作,但下一次工作正常(calling a function on the first time won't work as expected, but next time is working)
  • 如何优化使用BigInteger操作执行时间的代码(How to optimize the code that uses BigInteger operations for execution time)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何提供个人资料信息,以便Passport.js可以使用它?(how does Profile information should be provided so Passport.js can use it?)
  • 有没有办法初始化jquery数据表中的细节?(is there any way to initialize details in jquery datatable?)