小编mar*_*hon的帖子

我如何让Apache2 httpd使用ubuntu的CA证书进行Apache的出站SSL连接?

请注意,这不是关于让apache接受入站SSL连接的问题.

我有一个需要进行出站SSL连接的apache模块.当它尝试时,它会收到此错误:

Failed to send events: The OpenSSL library reported an error: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed:s3_clnt.c:1269:

这表明apache正在使用的SSL库不知道我的模块尝试连接的服务器的(有效)证书.

我运行的ubuntu系统上的CA证书很好,知道这个下游证书,openssl s_client告诉我一切正常.

如何告诉Apache2使用ubuntu的系统CA证书使出站连接有效?

更新 - 我做了一个strace -e open httpd -X,看看它试图从哪里加载证书.我看到apache打开libssl.so,但后来我甚至没有看到它试图打开通常的ssl.cnf或任何证书文件.

snipped useless strace output

update2:至于我是如何创建https请求的 - 我是从我的自定义apache模块中发出请求的.我的模块.so是用Rust编写的,所以连接代码基本上看起来像:

在mod_mine.so中:

use hyper::Client;
use hyper_tls::HttpsConnector;
use tokio_core::reactor::Core;

let mut core = Core::new()?;
let handle = core.handle();
let client = Client::configure()
    .connector(HttpsConnector::new(4, &handle)?)
    .build(&handle);

//actually a POST, but this gets the same error
let request = client.get("https://saas.mycompany.io".parse()?);
let result = core.run(request)?;
...  //process …
Run Code Online (Sandbox Code Playgroud)

apache ubuntu ssl https

7
推荐指数
1
解决办法
139
查看次数

有没有一种简单的方法可以在类路径中为Ant junit或java任务使用OSGi包?

我有一堆OSGi包,基本上是包含其他罐子和清单的罐子.

bundle xyz.jar:
   somejar1.jar
   somejar2.jar
   Manifest
Run Code Online (Sandbox Code Playgroud)

我想运行一些junit测试,并且需要在这些bundle中包含一些类.在Ant中有一个简单的方法可以说

<path name="myclasspath" location="[stuff inside OSGI bundle xyz.jar]>

我可以将这些解压缩到临时目录,但这看起来很乏味,而且我不会利用OSGi包中的类路径.

ant osgi classpath

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

适用于小块数据的良好压缩算法?(大约2k)

我有一个系统,一台机器以包含整数和长整数的对象的形式生成小块数据.这些块被传递给另一个服务器,后者又将它们分发到其他地方.

我想压缩这些对象,以减少传递服务器上的内存负载.我知道像deflate这样的压缩算法需要构建一个字典,所以像这样的东西不能真正处理这么小的数据.

是否有任何算法可以有效地压缩这样的数据?

如果没有,我可以做的另一件事是将这些块批处理成对象数组,并在数组达到一定大小后压缩它. 但我不愿意这样做,因为我必须更改现有系统中的接口.单独压缩它们不需要任何界面更改,这是所有设置的方式.

不是我认为这很重要,但目标系统是Java.

编辑:Elias gamma编码是否适合这种情况?

谢谢

compression algorithm

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

链接器错误 - 带有libboost_thread的macos上的未定义符号std :: string :: c_str()const?

我在macos mavericks上从自制软件安装了1.55.0增强版.获取链接器异常 - 找不到std :: string :: c_str(),我不明白为什么.这可能是自制软件的问题吗?我尝试直接从boost编译boost 1.55.0,它甚至没有在macos上构建.

这一点代码:

#include <iostream>
#include <unordered_map>
#include <vector>
#include <boost/thread/tss.hpp>

typedef std::unordered_map<std::string, std::string> StringMap;
static boost::thread_specific_ptr<std::vector<StringMap*>> rlist;


int main()
{
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

使用此命令行编译:

g++ -std=c++11 main.cpp -I/usr/local/include -L/usr/local/lib -lboost_thread -lboost_system -lboost_atomic -lboost_log -lstdc++
Run Code Online (Sandbox Code Playgroud)

抛出此链接器异常:

Undefined symbols for architecture x86_64:
  "std::string::c_str() const", referenced from:
      boost::system::system_error::what() const in libboost_thread.a(thread.o)
  "std::string::empty() const", referenced from:
      boost::system::system_error::what() const in libboost_thread.a(thread.o)
  "std::allocator<char>::allocator()", referenced from:
      boost::system::system_error::system_error(boost::system::error_code, char const*) in libboost_thread.a(thread.o)
      boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system.a(error_code.o)
  "std::allocator<char>::~allocator()", …
Run Code Online (Sandbox Code Playgroud)

c++ linker homebrew boost c++11

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

Spring Boot 属性值从 String 到 Duration 的转换在应用程序中有效,但在单元测试中失败

根据 spring 文档,诸如 之类的字符串属性值10s将被正确转换为java.time.Duration.

事实上,这对我来说适用于主要的应用程序属性。但它在单元测试中失败了。

单元测试

@ExtendWith(SpringExtension.class)
@EnableConfigurationProperties(value = MyConfig.class)
@TestPropertySource("classpath:test.properties")
public class MyUnitTest {
    @Autowired
    MyConfig config;
...
}
Run Code Online (Sandbox Code Playgroud)

配置类

@ConfigurationProperties(prefix = "my")
@Component
public class MyConfig {

    @Value("${my.failed-duration}")
    public Duration myDuration;
...
}
Run Code Online (Sandbox Code Playgroud)

测试.属性

my.failed-duration=10s
Run Code Online (Sandbox Code Playgroud)

例外

java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:244)
    at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:138)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$6(ClassBasedTestDescriptor.java:350)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:355)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$7(ClassBasedTestDescriptor.java:350)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) …
Run Code Online (Sandbox Code Playgroud)

java spring-boot spring-properties spring-boot-test

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

JAXB注释 - 如何创建XmlIDRef元素列表,将id值作为属性而不是元素正文文本?

更新 - 请参阅底部的编辑

IDRefs/keyrefs似乎可以在JAXB注释中使用,但ref最终是元素文本.

我希望ref成为元素的属性.

例如,给定此对象模型:

@XmlType
public class Employee {
    @XmlID
    @XmlAttribute
    String name;
    @XmlAttribute
    int years;
    @XmlAttribute
    String foo;
}

@XmlType
public class Office {
    @XmlAttribute
    String name;
    @XmlElementWrapper
    @XmlElement(name = "employee")
    List<Employee> employees;
}

@XmlRootElement
public class Company {
    @XmlElementWrapper
    @XmlElement(name = "office")
    List<Office> offices;
    @XmlElementWrapper
    @XmlElement(name = "employee")
    List<Employee> employees;
}
Run Code Online (Sandbox Code Playgroud)

我希望外化的xml格式最终看起来像这样:

<company>
    <offices>
        <office name="nyc">
            <employees>
                <!--*** id ref to employee name ***-->
                <employee ref="alice"/>
                <employee ref="bob"/>
            </employees>
        </office>
        <office name="sf">
            <employees>
                <employee ref="connie"/>
                <employee …
Run Code Online (Sandbox Code Playgroud)

java jaxb xml-serialization

5
推荐指数
1
解决办法
6177
查看次数

为什么这种自我引用的泛型分配是非法的?

我很难理解为什么会发生以下错误.如果#1没问题,为什么#2不行呢?

public interface IFoobar<DATA extends IFoobar> {
    void bigFun();
}

class FoobarImpl<DATA extends IFoobar> implements IFoobar<DATA> {
    public void bigFun() {
        DATA d = null;
        IFoobar<DATA> node = d;    //#1 ok
        d = node;                  //#2 error
    }
}
Run Code Online (Sandbox Code Playgroud)

java generics

5
推荐指数
2
解决办法
78
查看次数

可以用map-reduce方式计算一组数据的百分位数吗?

我的理解是计算百分位数,需要对数据进行排序.这可能是因为大量数据分布在多个服务器上而不会移动它们吗?

java statistics mapreduce percentile

5
推荐指数
1
解决办法
2579
查看次数

std :: atomic_is_lock_free()对于shared_ptr返回false。无锁并发shared_ptr操作还有其他选择吗?

我有一个shared_ptr,它将被多个线程访问。我使用shared_ptr 的std :: atomic 函数来使该线程安全。std :: atomic_is_lock_free()检查std :: atomic是否真正使用CPU原子操作而不是锁。

此功能的注释如下:

除std :: atomic_flag以外的所有原子类型都可以使用互斥锁或其他锁定操作来实现,而不是使用无锁原子CPU指令来实现。原子类型有时也可以是无锁的,例如,如果在给定的体系结构上,只有对齐的内存访问自然是原子的,则相同类型的未对齐对象必须使用锁。如果类型有时是无锁的,则必须使用函数(1)或其成员函数等效项来确定特定实例是否无锁。

在MacOS Mavericks(带有c ++ 11 std)和Linux CentOS 5.6(带有boost)上运行这段代码都返回false。我认为x86_64具有相当强大的原子操作。

#include <iostream>
#include <unordered_map>
#include <atomic>
#include <memory>

typedef std::unordered_map<std::string, std::string> StringMap;

int main()
{

    std::shared_ptr<StringMap> pMap;
    std::atomic_store(&pMap, std::make_shared<StringMap>());
    std::cout << "unordered_map ptr is lock free:" << std::boolalpha << std::atomic_is_lock_free(&pMap) << "\n";

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我的问题:就这些指针操作是无锁的而言,我是否很幸运,还是有其他选择?

编辑 这返回true:

std::atomic<StringMap*> apMap;
std::cout << "atomic ptr is lock free:" << std::boolalpha << apMap.is_lock_free() << "\n";
Run Code Online (Sandbox Code Playgroud)

c++ concurrency atomic shared-ptr c++11

5
推荐指数
0
解决办法
1275
查看次数

如何让intellij停止在项目结构视图中显示方法?

似乎在 2021 年 11 月版本的 Intellij 中,编辑器已开始在项目结构视图中显示方法。如果您的光标位于编辑器中的某个方法上,项目结构将打开并跳转到该方法。

我想禁用它并返回到不显示方法的旧式项目结构。

在此输入图像描述

java intellij-idea

5
推荐指数
1
解决办法
774
查看次数